Files
ShrlAlgoToolkit/Melskin/Controls/Label.xaml
2026-02-20 15:31:44 +08:00

71 lines
3.7 KiB
XML

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