Files
ShrlAlgoToolkit/NeuWPF/NeoUI/Controls/LabelStyle.xaml
ShrlAlgo 955a01f564 整理
2025-08-20 12:10:35 +08:00

71 lines
3.6 KiB
XML

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:assists="clr-namespace:NeoUI.Assists"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- 标签对象 -->
<Style TargetType="{x:Type Label}" x:Key="LabelBasic">
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="assists:ShadingAssist.DisabledForeground" Value="{DynamicResource TextDisabledBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Margin" Value="4" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Padding" Value="20,8" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Label}">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="true"
x:Name="contentBorder">
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
TextElement.Foreground="{TemplateBinding Foreground}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="contentPresenter" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{Binding Path=(assists:ShadingAssist.DisabledForeground), RelativeSource={RelativeSource TemplatedParent}}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style BasedOn="{StaticResource LabelBasic}" TargetType="{x:Type Label}" />
<Style
BasedOn="{StaticResource LabelBasic}"
TargetType="{x:Type Label}"
x:Key="LabelPrimary">
<Setter Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
<Setter Property="assists:ShadingAssist.DisabledForeground" Value="{DynamicResource PrimaryDisabledBrush}" />
</Style>
<Style
BasedOn="{StaticResource LabelBasic}"
TargetType="{x:Type Label}"
x:Key="LabelDanger">
<Setter Property="Foreground" Value="{StaticResource ErrorBrush}" />
<Setter Property="assists:ShadingAssist.DisabledForeground" Value="{StaticResource ErrorDisabledBrush}" />
</Style>
<Style
BasedOn="{StaticResource LabelBasic}"
TargetType="{x:Type Label}"
x:Key="LabelSuccess">
<Setter Property="Foreground" Value="{StaticResource SuccessBrush}" />
<Setter Property="assists:ShadingAssist.DisabledForeground" Value="{StaticResource SuccessDisabledBrush}" />
</Style>
</ResourceDictionary>