|
- <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
- <ControlTemplate x:Key="CbTemplate" TargetType="{x:Type CheckBox}">
- <Grid
- Name="gr"
- Background="Transparent"
- Opacity="1">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="auto" />
- <ColumnDefinition />
- </Grid.ColumnDefinitions>
-
- <Viewbox
- Width="{TemplateBinding Height}"
- Height="{TemplateBinding Height}"
- HorizontalAlignment="Left">
- <Grid Width="20" Height="20">
- <!-- 需要设置选择框的圆角 RadiusX="4" RadiusY="4" -->
- <Rectangle Stroke="{TemplateBinding Background}" />
- <!-- M:表示起始点 点1的位置 L:直线 点2的位置 点3的位置 点4的位置 点5的位置 Z:结束 -->
- <Path
- x:Name="path"
- Data="M 2,9 L 9,17 17,3 8,12 Z"
- Fill="{TemplateBinding Background}"
- RenderTransformOrigin="0.5,0.5"
- StrokeThickness="2">
- <Path.RenderTransform>
- <TransformGroup>
- <ScaleTransform ScaleX="0" ScaleY="0" />
- <SkewTransform />
- <RotateTransform />
- <TranslateTransform />
- </TransformGroup>
- </Path.RenderTransform>
- </Path>
- </Grid>
- </Viewbox>
- <ContentPresenter
- Name="cb"
- Grid.Column="1"
- Margin="5,0,0,0"
- HorizontalAlignment="Left"
- VerticalAlignment="Center" />
- </Grid>
-
- <ControlTemplate.Triggers>
- <Trigger Property="IsChecked" Value="True">
- <Trigger.ExitActions>
- <BeginStoryboard>
- <Storyboard>
- <DoubleAnimationUsingKeyFrames Storyboard.TargetName="path" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
- <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0" />
- </DoubleAnimationUsingKeyFrames>
- <DoubleAnimationUsingKeyFrames Storyboard.TargetName="path" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
- <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0" />
- </DoubleAnimationUsingKeyFrames>
- </Storyboard>
- </BeginStoryboard>
- </Trigger.ExitActions>
-
- <Trigger.EnterActions>
- <BeginStoryboard>
- <Storyboard>
- <DoubleAnimationUsingKeyFrames Storyboard.TargetName="path" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
- <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="1" />
- </DoubleAnimationUsingKeyFrames>
- <DoubleAnimationUsingKeyFrames Storyboard.TargetName="path" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
- <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="1" />
- </DoubleAnimationUsingKeyFrames>
- </Storyboard>
- </BeginStoryboard>
- </Trigger.EnterActions>
- </Trigger>
-
- <Trigger Property="IsEnabled" Value="false">
- <Setter TargetName="gr" Property="Opacity" Value="0.5" />
- </Trigger>
-
-
-
- <!--<Trigger Property="IsMouseOver" Value="true">
- <Setter TargetName="cb" Property="HorizontalAlignment" Value="Center" />
- </Trigger>-->
-
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </ResourceDictionary>
|