月更
This commit is contained in:
194
AntDesignWPF/Styles/CheckBox.xaml
Normal file
194
AntDesignWPF/Styles/CheckBox.xaml
Normal file
@@ -0,0 +1,194 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:controls="clr-namespace:AntDesign.WPF.Controls"
|
||||
xmlns:helpers="clr-namespace:AntDesign.WPF.Helpers"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/AntDesign.WPF;component/Styles/Animations.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/AntDesign.WPF;component/Styles/Control.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style
|
||||
BasedOn="{StaticResource Ant.Control}"
|
||||
TargetType="{x:Type CheckBox}"
|
||||
x:Key="Ant.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}" />
|
||||
<Setter Property="helpers:AntdControl.CornerRadius" Value="{DynamicResource BorderRadiusSmall}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type CheckBox}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<!-- Effect -->
|
||||
<Border
|
||||
BorderBrush="{DynamicResource CheckBoxBrush}"
|
||||
BorderThickness="1"
|
||||
CornerRadius="{Binding CornerRadius, Mode=OneWay, ElementName=Inner}"
|
||||
Height="{DynamicResource CheckBoxSize}"
|
||||
Opacity="0"
|
||||
RenderTransformOrigin="0.5,0.5"
|
||||
Width="{DynamicResource CheckBoxSize}"
|
||||
x:Name="Effect">
|
||||
<Border.RenderTransform>
|
||||
<ScaleTransform ScaleX="1" ScaleY="1" />
|
||||
</Border.RenderTransform>
|
||||
</Border>
|
||||
<!-- Inner -->
|
||||
<Border
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding helpers:AntdControl.CornerRadius}"
|
||||
Height="{DynamicResource CheckBoxSize}"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||||
UseLayoutRounding="True"
|
||||
Width="{DynamicResource CheckBoxSize}"
|
||||
x:Name="Inner" />
|
||||
<Path
|
||||
Data="M0,7 L3,7 3,0 5.6,0 5.6,9.6 0,9.6z"
|
||||
Fill="White"
|
||||
Height="11"
|
||||
HorizontalAlignment="Center"
|
||||
Opacity="0"
|
||||
RenderTransformOrigin="0.5,0.5"
|
||||
VerticalAlignment="Center"
|
||||
Width="7"
|
||||
x:Name="CheckedMark">
|
||||
<Path.RenderTransform>
|
||||
<TransformGroup>
|
||||
<RotateTransform Angle="45" />
|
||||
<ScaleTransform ScaleX="0" ScaleY="0" x:Name="CheckedMarkTransform" />
|
||||
</TransformGroup>
|
||||
</Path.RenderTransform>
|
||||
</Path>
|
||||
<Rectangle
|
||||
Fill="{DynamicResource CheckBoxBrush}"
|
||||
Height="{DynamicResource CheckBoxIndeterminateSize}"
|
||||
HorizontalAlignment="Center"
|
||||
Opacity="0"
|
||||
RenderTransformOrigin="0.5,0.5"
|
||||
VerticalAlignment="Center"
|
||||
Width="{DynamicResource CheckBoxIndeterminateSize}"
|
||||
x:Name="IndeterminateMark">
|
||||
<Rectangle.RenderTransform>
|
||||
<ScaleTransform ScaleX="0" ScaleY="0" />
|
||||
</Rectangle.RenderTransform>
|
||||
</Rectangle>
|
||||
<!-- Content -->
|
||||
<ContentPresenter
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentStringFormat="{TemplateBinding ContentStringFormat}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
Margin="{TemplateBinding Padding}"
|
||||
RecognizesAccessKey="True"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CheckStates">
|
||||
<VisualState x:Name="Checked">
|
||||
<Storyboard>
|
||||
<!-- CheckedMark -->
|
||||
<DoubleAnimation
|
||||
Duration="0:0:0.2"
|
||||
EasingFunction="{StaticResource EaseOutBack}"
|
||||
Storyboard.TargetName="CheckedMark"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
To="1" />
|
||||
<DoubleAnimation
|
||||
Duration="0:0:0.2"
|
||||
EasingFunction="{StaticResource EaseOutBack}"
|
||||
Storyboard.TargetName="CheckedMarkTransform"
|
||||
Storyboard.TargetProperty="ScaleX"
|
||||
To="1" />
|
||||
<DoubleAnimation
|
||||
Duration="0:0:0.2"
|
||||
EasingFunction="{StaticResource EaseOutBack}"
|
||||
Storyboard.TargetName="CheckedMarkTransform"
|
||||
Storyboard.TargetProperty="ScaleY"
|
||||
To="1" />
|
||||
|
||||
<!-- Effect -->
|
||||
<DoubleAnimation
|
||||
Duration="0:0:0.36"
|
||||
EasingFunction="{StaticResource EaseInOut}"
|
||||
From="0.5"
|
||||
Storyboard.TargetName="Effect"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
To="0" />
|
||||
<DoubleAnimation
|
||||
Duration="0:0:0.36"
|
||||
EasingFunction="{StaticResource EaseInOut}"
|
||||
Storyboard.TargetName="Effect"
|
||||
Storyboard.TargetProperty="RenderTransform.ScaleX"
|
||||
To="1.6" />
|
||||
<DoubleAnimation
|
||||
Duration="0:0:0.36"
|
||||
EasingFunction="{StaticResource EaseInOut}"
|
||||
Storyboard.TargetName="Effect"
|
||||
Storyboard.TargetProperty="RenderTransform.ScaleY"
|
||||
To="1.6" />
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Unchecked" />
|
||||
<VisualState x:Name="Indeterminate">
|
||||
<Storyboard>
|
||||
<DoubleAnimation
|
||||
Duration="0:0:0.1"
|
||||
EasingFunction="{StaticResource EaseInBack}"
|
||||
Storyboard.TargetName="IndeterminateMark"
|
||||
Storyboard.TargetProperty="Opacity"
|
||||
To="1" />
|
||||
<DoubleAnimation
|
||||
Duration="0:0:0.1"
|
||||
EasingFunction="{StaticResource EaseInBack}"
|
||||
Storyboard.TargetName="IndeterminateMark"
|
||||
Storyboard.TargetProperty="RenderTransform.ScaleX"
|
||||
To="1" />
|
||||
<DoubleAnimation
|
||||
Duration="0:0:0.1"
|
||||
EasingFunction="{StaticResource EaseInBack}"
|
||||
Storyboard.TargetName="IndeterminateMark"
|
||||
Storyboard.TargetProperty="RenderTransform.ScaleY"
|
||||
To="1" />
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter Property="Background" TargetName="Inner" Value="{DynamicResource CheckBoxBrush}" />
|
||||
<Setter Property="BorderBrush" TargetName="Inner" Value="{DynamicResource CheckBoxBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="BorderBrush" TargetName="Inner" Value="{DynamicResource CheckBoxBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsFocused" Value="True">
|
||||
<Setter Property="BorderBrush" TargetName="Inner" Value="{DynamicResource CheckBoxBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Foreground" Value="{DynamicResource DisabledBrush}" />
|
||||
<Setter Property="Background" TargetName="Inner" Value="{DynamicResource InputDisabledBackground}" />
|
||||
<Setter Property="BorderBrush" TargetName="Inner" Value="{DynamicResource BorderBrushBase}" />
|
||||
<Setter Property="Fill" TargetName="CheckedMark" Value="{DynamicResource DisabledBrush}" />
|
||||
<Setter Property="Fill" TargetName="IndeterminateMark" Value="{DynamicResource DisabledBrush}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user