Skip to content

Commit e964b0e

Browse files
committed
[Linux] Add Label styling
1 parent ed576e1 commit e964b0e

File tree

4 files changed

+52
-6
lines changed

4 files changed

+52
-6
lines changed

samples/SampleApp/DemoPages/LabelDemo.axaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</StackPanel>
1313

1414
<StackPanel>
15-
<Label Content="Label disabled" IsEnabled="False" Target="{Binding #Input2}" />
15+
<Label Content="Label explicitly disabled" IsEnabled="False" Target="{Binding #Input2}" />
1616
<TextBox Name="Input2" Text="Linked input control not affected" />
1717
</StackPanel>
1818

@@ -32,14 +32,22 @@
3232
</StackPanel>
3333

3434
<StackPanel>
35-
<Label Content="Label.form" Classes="form" Target="{Binding #Input6}" />
35+
<Label Classes="form" Target="{Binding #Input6}">
36+
<Label.Content>
37+
<TextBlock>Label with <TextBlock Classes="code" Text="&lt;Label Classes=&quot;form&quot;&gt;" /></TextBlock>
38+
</Label.Content>
39+
</Label>
3640
<TextBox Name="Input6" Text="Colon automatically added" />
3741
</StackPanel>
3842

3943

40-
<TextBlock Classes="section-title" Text="Grid.form or Grid.compact-form" Margin="0 20 0 0" />
41-
<TextBlock Text="Colons added to all labels" />
42-
<Grid Classes="form" ColumnDefinitions="Auto, *" RowDefinitions="Auto,Auto" Margin="10 0">
44+
<TextBlock Margin="0 20 0 0">
45+
<TextBlock Classes="code" Text="Grid.form" /> or
46+
<TextBlock Classes="code" Text="Grid.compact-form" />
47+
<LineBreak /> --&gt; Colons added to all labels
48+
</TextBlock>
49+
50+
<Grid Classes="form" ColumnDefinitions="Auto, *" RowDefinitions="Auto,Auto" Margin="10 0" ColumnSpacing="4" RowSpacing="4">
4351
<Label Content="_First" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Target="{Binding #FirstNameBox}" />
4452
<TextBox Name="FirstNameBox" Grid.Row="0" Grid.Column="1" Text="Otto" />
4553

samples/SampleApp/MainWindow.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
</TabItem>
121121
<TabItem IsSelected="True">
122122
<TabItem.Header>
123-
<controls:SampleItemHeader Title="Label" ApplicableTo="MacOS" />
123+
<controls:SampleItemHeader Title="Label" ApplicableTo="MacOS, Windows - DevExpress, Linux - Yaru" />
124124
</TabItem.Header>
125125
<demoPages:LabelDemo />
126126
</TabItem>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!-- Based off https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Themes.Fluent/Controls/Label.xaml -->
2+
3+
<ResourceDictionary xmlns="https://github.com/avaloniaui"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
x:ClassModifier="internal">
6+
7+
<ControlTheme x:Key="{x:Type Label}" TargetType="Label">
8+
<Setter Property="Padding" Value="3" />
9+
<Setter Property="IsEnabled" Value="{Binding $self.Target.IsEnabled, FallbackValue=True}" />
10+
<Setter Property="Template">
11+
<ControlTemplate>
12+
<StackPanel Orientation="Horizontal" Margin="{TemplateBinding Padding}">
13+
<ContentPresenter Name="PART_ContentPresenter"
14+
Background="{TemplateBinding Background}"
15+
BorderBrush="{TemplateBinding BorderBrush}"
16+
BorderThickness="{TemplateBinding BorderThickness}"
17+
CornerRadius="{TemplateBinding CornerRadius}"
18+
ContentTemplate="{TemplateBinding ContentTemplate}"
19+
Content="{TemplateBinding Content}"
20+
RecognizesAccessKey="True"
21+
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
22+
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" />
23+
<!-- TextBlock#Colon can be used in styles to automatically display colon after each label (cp. SampleApp/styles.axaml) -->
24+
<TextBlock
25+
Name="Colon"
26+
Text=":"
27+
IsVisible="False" />
28+
</StackPanel>
29+
</ControlTemplate>
30+
</Setter>
31+
32+
<Style Selector="^:disabled">
33+
<Setter Property="Foreground" Value="{DynamicResource ForegroundLowBrush}" />
34+
</Style>
35+
36+
</ControlTheme>
37+
</ResourceDictionary>

src/Devolutions.AvaloniaTheme.Linux/Controls/_index.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<MergeResourceInclude Source="DataGrid.axaml" />
1515
<MergeResourceInclude Source="EmbeddableControlRoot.axaml" />
1616
<MergeResourceInclude Source="Expander.axaml" />
17+
<MergeResourceInclude Source="Label.axaml" />
1718
<MergeResourceInclude Source="ListBox.axaml" />
1819
<MergeResourceInclude Source="NumericUpDown.axaml" />
1920
<MergeResourceInclude Source="TabItem.axaml" />

0 commit comments

Comments
 (0)