Merge pull request #118 from irihitech/0312fix

fix: Fix Textblock/SelectableTextBlock/Label disable style and textdecoration combination.
This commit is contained in:
Zhang Dian 2023-03-09 16:45:06 +08:00 committed by GitHub
commit ffc5b120b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 17 deletions

View File

@ -1,11 +1,16 @@
<UserControl
x:Class="Semi.Avalonia.Demo.Pages.TextBlockDemo" 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" d:DesignHeight="600"
d:DesignWidth="800" mc:Ignorable="d">
x:Class="Semi.Avalonia.Demo.Pages.TextBlockDemo"
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"
d:DesignHeight="600"
d:DesignWidth="800"
mc:Ignorable="d">
<StackPanel Orientation="Horizontal">
<StackPanel
Margin="20" HorizontalAlignment="Left"
Margin="20"
HorizontalAlignment="Left"
Spacing="5">
<TextBlock>Styles for TextBlock</TextBlock>
<TextBlock Classes="H1" Theme="{StaticResource TitleTextBlock}">Header 1</TextBlock>
@ -20,15 +25,18 @@
<TextBlock Classes="Tertiary">Tertiary</TextBlock>
<TextBlock Classes="Quaternary">Quaternary</TextBlock>
<TextBlock Classes="Warning">Warning</TextBlock>
<TextBlock Classes="Warning" IsEnabled="False">Warning disabled</TextBlock>
<TextBlock Classes="Danger">Danger</TextBlock>
<TextBlock Classes="Success">Success</TextBlock>
<TextBlock IsEnabled="False">Disabled</TextBlock>
<TextBlock Classes="Mark">Default Mark</TextBlock>
<TextBlock Classes="Underline">Underline</TextBlock>
<TextBlock Classes="Delete">Delete</TextBlock>
<TextBlock Classes="Underline Delete">Underline and Delete</TextBlock>
</StackPanel>
<StackPanel
Margin="20" HorizontalAlignment="Left"
Margin="20"
HorizontalAlignment="Left"
Spacing="5">
<TextBlock>Styles for SelectableTextBlock</TextBlock>
<SelectableTextBlock Classes="H1" Theme="{StaticResource TitleSelectableTextBlock}">Header 1</SelectableTextBlock>
@ -43,15 +51,18 @@
<SelectableTextBlock Classes="Tertiary">Tertiary</SelectableTextBlock>
<SelectableTextBlock Classes="Quaternary">Quaternary</SelectableTextBlock>
<SelectableTextBlock Classes="Warning">Warning</SelectableTextBlock>
<SelectableTextBlock Classes="Warning" IsEnabled="False">Warning disabled</SelectableTextBlock>
<SelectableTextBlock Classes="Danger">Danger</SelectableTextBlock>
<SelectableTextBlock Classes="Success">Success</SelectableTextBlock>
<SelectableTextBlock IsEnabled="False">Disabled</SelectableTextBlock>
<SelectableTextBlock Classes="Mark">Default Mark</SelectableTextBlock>
<SelectableTextBlock Classes="Underline">Underline</SelectableTextBlock>
<SelectableTextBlock Classes="Delete">Delete</SelectableTextBlock>
<SelectableTextBlock Classes="Underline Delete">Underline and Delete</SelectableTextBlock>
</StackPanel>
<StackPanel
Margin="20" HorizontalAlignment="Left"
Margin="20"
HorizontalAlignment="Left"
Spacing="5">
<TextBlock>Styles for Label</TextBlock>
<Label Classes="H1" Theme="{StaticResource TitleLabel}">Header 1</Label>
@ -66,6 +77,7 @@
<Label Classes="Tertiary">Tertiary</Label>
<Label Classes="Quaternary">Quaternary</Label>
<Label Classes="Warning">Warning</Label>
<Label Classes="Warning" IsEnabled="False">Warning disabled</Label>
<Label Classes="Danger">Danger</Label>
<Label Classes="Success">Success</Label>
<Label IsEnabled="False">Disabled</Label>

View File

@ -99,9 +99,6 @@
RecognizesAccessKey="True" />
</ControlTemplate>
</Setter>
<Style Selector="^:disabled">
<Setter Property="Label.Foreground" Value="{DynamicResource TextBlockDisabledForeground}" />
</Style>
<Style Selector="^.Secondary">
<Setter Property="Label.Foreground" Value="{DynamicResource TextBlockSecondaryForeground}" />
</Style>
@ -133,6 +130,9 @@
<Setter Property="Label.FontFamily" Value="{DynamicResource CodeFontFamily}" />
<Setter Property="Label.FontSize" Value="{DynamicResource TextBlockCodeFontSize}" />
</Style>
<Style Selector="^:disabled">
<Setter Property="Label.Foreground" Value="{DynamicResource TextBlockDisabledForeground}" />
</Style>
</ControlTheme>
<ControlTheme
x:Key="TitleLabel"

View File

@ -17,9 +17,6 @@
<Setter Property="SelectableTextBlock.FontSize" Value="{DynamicResource TextBlockFontSize}" />
<Setter Property="SelectableTextBlock.Cursor" Value="Ibeam" />
<Setter Property="SelectableTextBlock.SelectionBrush" Value="{DynamicResource TextBlockSelectionBackground}" />
<Style Selector="^:disabled">
<Setter Property="SelectableTextBlock.Foreground" Value="{DynamicResource TextBlockDisabledForeground}" />
</Style>
<Style Selector="^.Secondary">
<Setter Property="SelectableTextBlock.Foreground" Value="{DynamicResource TextBlockSecondaryForeground}" />
</Style>
@ -47,8 +44,18 @@
<Style Selector="^.Delete">
<Setter Property="SelectableTextBlock.TextDecorations" Value="StrikeThrough" />
</Style>
<Style Selector="^.Underline.Delete">
<Setter Property="TextBlock.TextDecorations">
<TextDecorationCollection>
<TextDecoration Location="Underline" />
<TextDecoration Location="Strikethrough" />
</TextDecorationCollection>
</Setter>
</Style>
<Style Selector="^:disabled">
<Setter Property="SelectableTextBlock.Foreground" Value="{DynamicResource TextBlockDisabledForeground}" />
</Style>
<Style Selector="^[IsEnabled=True]">
<Setter Property="Cursor" Value="IBeam" />
<Setter Property="ContextFlyout" Value="{StaticResource SelectableTextBlockContextFlyout}" />
</Style>
</ControlTheme>
@ -75,5 +82,8 @@
<Style Selector="^.H6">
<Setter Property="SelectableTextBlock.FontSize" Value="{DynamicResource TextBlockTitleH6FontSize}" />
</Style>
<Style Selector="^:disabled">
<Setter Property="SelectableTextBlock.Foreground" Value="{DynamicResource TextBlockDisabledForeground}" />
</Style>
</ControlTheme>
</ResourceDictionary>

View File

@ -10,9 +10,6 @@
<ControlTheme x:Key="{x:Type TextBlock}" TargetType="TextBlock">
<!--<Setter Property="TextBlock.Foreground" Value="{DynamicResource TextBlockDefaultForeground}" />-->
<Setter Property="TextBlock.FontSize" Value="{DynamicResource TextBlockFontSize}" />
<Style Selector="^:disabled">
<Setter Property="TextBlock.Foreground" Value="{DynamicResource TextBlockDisabledForeground}" />
</Style>
<Style Selector="^.Secondary">
<Setter Property="TextBlock.Foreground" Value="{DynamicResource TextBlockSecondaryForeground}" />
</Style>
@ -40,6 +37,17 @@
<Style Selector="^.Delete">
<Setter Property="TextBlock.TextDecorations" Value="StrikeThrough" />
</Style>
<Style Selector="^.Underline.Delete">
<Setter Property="TextBlock.TextDecorations">
<TextDecorationCollection>
<TextDecoration Location="Underline" />
<TextDecoration Location="Strikethrough" />
</TextDecorationCollection>
</Setter>
</Style>
<Style Selector="^:disabled">
<Setter Property="TextBlock.Foreground" Value="{DynamicResource TextBlockDisabledForeground}" />
</Style>
</ControlTheme>
<ControlTheme
x:Key="TitleTextBlock"
@ -64,5 +72,8 @@
<Style Selector="^.H6">
<Setter Property="TextBlock.FontSize" Value="{DynamicResource TextBlockTitleH6FontSize}" />
</Style>
<Style Selector="^:disabled">
<Setter Property="SelectableTextBlock.Foreground" Value="{DynamicResource TextBlockDisabledForeground}" />
</Style>
</ControlTheme>
</ResourceDictionary>