Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions samples/SampleApp/DemoPages/LabelDemo.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SampleApp.DemoPages.LabelDemo">

<StackPanel Margin="10" Width="350" Spacing="15" HorizontalAlignment="Left">
<StackPanel>
<Label Content="Label" Target="{Binding #Input1}" />
<TextBox Name="Input1" Text="Input" />
</StackPanel>

<StackPanel>
<Label Content="Label disabled" IsEnabled="False" Target="{Binding #Input2}" />
<TextBox Name="Input2" Text="Linked input control not affected" />
</StackPanel>

<StackPanel IsEnabled="False">
<Label Content="Container disabled" Target="{Binding #Input3}" />
<TextBox Name="Input3" Text="Input" />
</StackPanel>

<StackPanel>
<Label Content="Linked control disabled" Target="{Binding #Input4}" />
<TextBox Name="Input4" Text="Input" IsEnabled="False" />
</StackPanel>

<StackPanel>
<Label Content="_Label not linked to Target" />
<TextBox Name="Input5" Text="No mnemonics, no accesibility, no label-click-to-focus" />
</StackPanel>

<StackPanel>
<Label Content="Label.form" Classes="form" Target="{Binding #Input6}" />
<TextBox Name="Input6" Text="Colon automatically added" />
</StackPanel>


<TextBlock Classes="section-title" Text="Grid.form or Grid.compact-form" Margin="0 20 0 0" />
<TextBlock Text="Colons added to all labels" />
<Grid Classes="form" ColumnDefinitions="Auto, *" RowDefinitions="Auto,Auto" Margin="10 0">
<Label Content="_First" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Target="{Binding #FirstNameBox}" />
<TextBox Name="FirstNameBox" Grid.Row="0" Grid.Column="1" Text="Otto" />

<Label Content="Last Name" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" Target="{Binding #LastNameBox}" />
<TextBox Name="LastNameBox" Grid.Row="1" Grid.Column="1" IsEnabled="False" Text="Smith" />
</Grid>


</StackPanel>


</UserControl>
13 changes: 13 additions & 0 deletions samples/SampleApp/DemoPages/LabelDemo.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;

namespace SampleApp.DemoPages;

public partial class LabelDemo : UserControl
{
public LabelDemo()
{
InitializeComponent();
}
}
8 changes: 7 additions & 1 deletion samples/SampleApp/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
</TabItem.Header>
<demoPages:EditableComboBoxDemo />
</TabItem>
<TabItem IsSelected="True">
<TabItem>
<TabItem.Header>
<controls:SampleItemHeader Title="Expander" ApplicableTo="MacOS, Windows - DevExpress" />
</TabItem.Header>
Expand Down Expand Up @@ -118,6 +118,12 @@
</TabItem.Header>
<demoPages:GridSplitterDemo />
</TabItem>
<TabItem IsSelected="True">
<TabItem.Header>
<controls:SampleItemHeader Title="Label" ApplicableTo="MacOS" />
</TabItem.Header>
<demoPages:LabelDemo />
</TabItem>
<TabItem>
<TabItem.Header>
<controls:SampleItemHeader Title="ListBox" ApplicableTo="MacOS, Windows - DevExpress" />
Expand Down
12 changes: 10 additions & 2 deletions samples/SampleApp/Styles.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

<Style Selector="Border.alternativeBackground">
<Setter Property="Background" Value="{DynamicResource AlternativeBackgroundBrush}" />
</Style>
</Style>

<Style Selector="Panel.mainControl">
<Setter Property="Background" Value="{DynamicResource BackgroundBrush}" />
</Style>
Expand All @@ -43,4 +43,12 @@
<Setter Property="Padding" Value="4,0,4,0" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>

<!-- This rule is also used in RDM Styles.MacOS-->
<Style
Selector="Grid.form > Label /template/ TextBlock#Colon,
Label.form /template/ TextBlock#Colon,
.compact-form > Label /template/ TextBlock#Colon">
<Setter Property="IsVisible" Value="True" />
</Style>
</Styles>
37 changes: 37 additions & 0 deletions src/Devolutions.AvaloniaTheme.MacOS/Controls/Label.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!-- Based off https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Themes.Fluent/Controls/Label.xaml -->

<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal">

<ControlTheme x:Key="{x:Type Label}" TargetType="Label">
<Setter Property="Padding" Value="3" />
<Setter Property="IsEnabled" Value="{Binding $self.Target.IsEnabled, FallbackValue=True}" />
<Setter Property="Template">
<ControlTemplate>
<StackPanel Orientation="Horizontal" Margin="{TemplateBinding Padding}">
<ContentPresenter Name="PART_ContentPresenter"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}"
RecognizesAccessKey="True"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" />
<!-- TextBlock#Colon can be used in styles to automatically display colon after each label (cp. SampleApp/styles.axaml) -->
<TextBlock
Name="Colon"
Text=":"
IsVisible="False" />
</StackPanel>
</ControlTemplate>
</Setter>

<Style Selector="^:disabled">
<Setter Property="Foreground" Value="{DynamicResource ForegroundLowBrush}" />
</Style>

</ControlTheme>
</ResourceDictionary>
1 change: 1 addition & 0 deletions src/Devolutions.AvaloniaTheme.MacOS/Controls/_index.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<MergeResourceInclude Source="EditableComboBox.axaml" />
<MergeResourceInclude Source="Expander.axaml" />
<MergeResourceInclude Source="GridSplitter.axaml" />
<MergeResourceInclude Source="Label.axaml" />
<MergeResourceInclude Source="ListBox.axaml" />
<MergeResourceInclude Source="ListBoxItem.axaml" />
<MergeResourceInclude Source="Menu.axaml" />
Expand Down