Files
Shrlalgo.RvKits/WPFDark/StandardControls/CheckBox.xaml
ShrlAlgo 4d35cadb56 更新
2025-07-11 09:20:23 +08:00

97 lines
6.2 KiB
XML

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wpf="clr-namespace:WPFDark">
<Style TargetType="{x:Type CheckBox}">
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Background" Value="{DynamicResource TextBoxBackgroundBrushKey}" />
<Setter Property="BorderBrush" Value="{DynamicResource ActiveBorderBrushKey}" />
<Setter Property="Foreground" Value="{DynamicResource ForegroundBrushKey}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Padding" Value="4,0,0,0" />
<Setter Property="FocusVisualStyle" Value="{DynamicResource {x:Static SystemParameters.FocusVisualStyleKey}}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type CheckBox}">
<Grid Background="Transparent" SnapsToDevicePixels="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border x:Name="checkBoxBorder"
Width="16"
Height="16"
Margin="0,2"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="Center"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{x:Static wpf:Boxes.BasicCornerRadius}">
<Path x:Name="optionMark"
Margin="-1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="F1 M 9.97498,1.22334L 4.6983,9.09834L 4.52164,9.09834L 0,5.19331L 1.27664,3.52165L 4.255,6.08833L 8.33331,1.52588e-005L 9.97498,1.22334 Z "
Fill="{DynamicResource AccentBrushKey}"
Opacity="0.0"
Stretch="None" />
</Border>
<ContentPresenter Grid.Column="1"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Focusable="False"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="optionMark" Property="Opacity" Value="0.0" />
<Setter TargetName="checkBoxBorder" Property="BorderBrush" Value="{DynamicResource AccentBrushKey}" />
<Setter TargetName="checkBoxBorder" Property="BorderThickness" Value="1" />
<Setter Property="Foreground" Value="{DynamicResource ActiveForegroundBrushKey}" />
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter TargetName="checkBoxBorder" Property="BorderThickness" Value="0" />
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="optionMark" Property="Opacity" Value="1.0" />
<Setter TargetName="optionMark" Property="Fill" Value="{DynamicResource BackgroundBackgroundBrushKey}" />
<Setter TargetName="checkBoxBorder" Property="Background" Value="{DynamicResource AccentBrushKey}" />
<Setter TargetName="checkBoxBorder" Property="BorderThickness" Value="0" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="optionMark" Property="Fill" Value="{DynamicResource InactiveForegroundBrushKey}" />
<Setter TargetName="checkBoxBorder" Property="BorderBrush" Value="{DynamicResource InactiveBorderBrushKey}" />
<Setter TargetName="checkBoxBorder" Property="Background" Value="Transparent" />
<Setter TargetName="checkBoxBorder" Property="BorderThickness" Value="1" />
<Setter Property="Foreground" Value="{DynamicResource InactiveForegroundBrushKey}" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="optionMark" Property="Fill" Value="{DynamicResource AccentBrushKey}" />
<Setter TargetName="checkBoxBorder" Property="Background" Value="{DynamicResource AccentBrushKey}" />
<Setter TargetName="checkBoxBorder" Property="BorderThickness" Value="0" />
<Setter Property="Foreground" Value="{DynamicResource AccentBrushKey}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>