Files
Shrlalgo.RvKits/AntdWpf/Styles/CheckBox.xaml

176 lines
12 KiB
Plaintext
Raw Normal View History

2025-07-11 09:20:23 +08:00
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:AntdWpf.Controls"
xmlns:helpers="clr-namespace:AntdWpf.Helpers">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/AntdWpf;component/Styles/Animations.xaml" />
<ResourceDictionary Source="pack://application:,,,/AntdWpf;component/Styles/Control.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style x:Key="Ant.CheckBox" BasedOn="{StaticResource Ant.Control}" TargetType="{x:Type CheckBox}">
<Setter Property="Padding" Value="4 0 8 0" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="Background" Value="{DynamicResource ComponentBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrushBase}" />
<Setter Property="BorderThickness" Value="{DynamicResource BorderThicknessBase}" />
2025-07-12 23:31:32 +08:00
<Setter Property="helpers:AntdControl.CornerRadius" Value="{DynamicResource BorderRadiusSmall}" />
2025-07-11 09:20:23 +08:00
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type CheckBox}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- Effect -->
<Border x:Name="Effect"
Opacity="0"
BorderThickness="1"
RenderTransformOrigin="0.5,0.5"
Width="{DynamicResource CheckBoxSize}"
Height="{DynamicResource CheckBoxSize}"
BorderBrush="{DynamicResource CheckBoxBrush}"
CornerRadius="{Binding CornerRadius, Mode=OneWay, ElementName=Inner}">
<Border.RenderTransform>
<ScaleTransform ScaleX="1" ScaleY="1" />
</Border.RenderTransform>
</Border>
<!-- Inner -->
<Border x:Name="Inner"
UseLayoutRounding="True"
Width="{DynamicResource CheckBoxSize}"
Height="{DynamicResource CheckBoxSize}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
2025-07-12 23:31:32 +08:00
CornerRadius="{TemplateBinding helpers:AntdControl.CornerRadius}" />
2025-07-11 09:20:23 +08:00
<Path x:Name="CheckedMark"
Fill="White"
Width="7"
Height="11"
Opacity="0"
VerticalAlignment="Center"
HorizontalAlignment="Center"
RenderTransformOrigin="0.5,0.5"
Data="M0,7 L3,7 3,0 5.6,0 5.6,9.6 0,9.6z">
<Path.RenderTransform>
<TransformGroup>
<RotateTransform Angle="45" />
<ScaleTransform x:Name="CheckedMarkTransform" ScaleX="0" ScaleY="0" />
</TransformGroup>
</Path.RenderTransform>
</Path>
<Rectangle x:Name="IndeterminateMark"
Opacity="0"
VerticalAlignment="Center"
HorizontalAlignment="Center"
RenderTransformOrigin="0.5,0.5"
Fill="{DynamicResource CheckBoxBrush}"
Width="{DynamicResource CheckBoxIndeterminateSize}"
Height="{DynamicResource CheckBoxIndeterminateSize}">
<Rectangle.RenderTransform>
<ScaleTransform ScaleX="0" ScaleY="0" />
</Rectangle.RenderTransform>
</Rectangle>
<!-- Content -->
<ContentPresenter Grid.Column="1"
RecognizesAccessKey="True"
Margin="{TemplateBinding Padding}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" />
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CheckStates">
<VisualState x:Name="Checked">
<Storyboard>
<!-- CheckedMark -->
<DoubleAnimation Storyboard.TargetName="CheckedMark"
Storyboard.TargetProperty="Opacity"
EasingFunction="{StaticResource EaseOutBack}"
Duration="0:0:0.2"
To="1" />
<DoubleAnimation Storyboard.TargetName="CheckedMarkTransform"
Storyboard.TargetProperty="ScaleX"
EasingFunction="{StaticResource EaseOutBack}"
Duration="0:0:0.2"
To="1" />
<DoubleAnimation Storyboard.TargetName="CheckedMarkTransform"
Storyboard.TargetProperty="ScaleY"
EasingFunction="{StaticResource EaseOutBack}"
Duration="0:0:0.2"
To="1" />
<!-- Effect -->
<DoubleAnimation Storyboard.TargetName="Effect"
Storyboard.TargetProperty="Opacity"
EasingFunction="{StaticResource EaseInOut}"
Duration="0:0:0.36"
From="0.5"
To="0" />
<DoubleAnimation Storyboard.TargetName="Effect"
Storyboard.TargetProperty="RenderTransform.ScaleX"
EasingFunction="{StaticResource EaseInOut}"
Duration="0:0:0.36"
To="1.6" />
<DoubleAnimation Storyboard.TargetName="Effect"
Storyboard.TargetProperty="RenderTransform.ScaleY"
EasingFunction="{StaticResource EaseInOut}"
Duration="0:0:0.36"
To="1.6" />
</Storyboard>
</VisualState>
<VisualState x:Name="Unchecked" />
<VisualState x:Name="Indeterminate">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="IndeterminateMark"
Storyboard.TargetProperty="Opacity"
EasingFunction="{StaticResource EaseInBack}"
Duration="0:0:0.1"
To="1" />
<DoubleAnimation Storyboard.TargetName="IndeterminateMark"
Storyboard.TargetProperty="RenderTransform.ScaleX"
EasingFunction="{StaticResource EaseInBack}"
Duration="0:0:0.1"
To="1" />
<DoubleAnimation Storyboard.TargetName="IndeterminateMark"
Storyboard.TargetProperty="RenderTransform.ScaleY"
EasingFunction="{StaticResource EaseInBack}"
Duration="0:0:0.1"
To="1" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="Inner" Property="Background" Value="{DynamicResource CheckBoxBrush}" />
<Setter TargetName="Inner" Property="BorderBrush" Value="{DynamicResource CheckBoxBrush}" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Inner" Property="BorderBrush" Value="{DynamicResource CheckBoxBrush}" />
</Trigger>
<Trigger Property="IsFocused" Value="True">
<Setter TargetName="Inner" Property="BorderBrush" Value="{DynamicResource CheckBoxBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource DisabledBrush}" />
<Setter TargetName="Inner" Property="Background" Value="{DynamicResource InputDisabledBackground}" />
<Setter TargetName="Inner" Property="BorderBrush" Value="{DynamicResource BorderBrushBase}" />
<Setter TargetName="CheckedMark" Property="Fill" Value="{DynamicResource DisabledBrush}" />
<Setter TargetName="IndeterminateMark" Property="Fill" Value="{DynamicResource DisabledBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>