AnimationButton.xaml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:ZUI="clr-namespace:CustomUI">
  4. <SolidColorBrush x:Key="TreeViewItem.TreeArrow.Static.Checked.Fill" Color="#FF595959" />
  5. <SolidColorBrush x:Key="TreeViewItem.TreeArrow.Static.Checked.Stroke" Color="#FF262626" />
  6. <SolidColorBrush x:Key="TreeViewItem.TreeArrow.MouseOver.Stroke" Color="#FF27C7F7" />
  7. <SolidColorBrush x:Key="TreeViewItem.TreeArrow.MouseOver.Fill" Color="#FFCCEEFB" />
  8. <SolidColorBrush x:Key="TreeViewItem.TreeArrow.MouseOver.Checked.Stroke" Color="#FF1CC4F7" />
  9. <SolidColorBrush x:Key="TreeViewItem.TreeArrow.MouseOver.Checked.Fill" Color="#FF82DFFB" />
  10. <PathGeometry x:Key="TreeArrow" Figures="M322.392 90.125l421.803 421.898-421.803 421.852v-843.75z" />
  11. <SolidColorBrush x:Key="TreeViewItem.TreeArrow.Static.Fill" Color="#657180" />
  12. <SolidColorBrush x:Key="TreeViewItem.TreeArrow.Static.Stroke" Color="#00818181" />
  13. <Style TargetType="{x:Type ZUI:AnimationButton}">
  14. <Setter Property="HorizontalContentAlignment" Value="Center" />
  15. <Setter Property="VerticalContentAlignment" Value="Center" />
  16. <Setter Property="Focusable" Value="True" />
  17. <Setter Property="Background" Value="Transparent" />
  18. <Setter Property="Template">
  19. <Setter.Value>
  20. <ControlTemplate TargetType="{x:Type ZUI:AnimationButton}">
  21. <Border x:Name="Bd" Background="{TemplateBinding Background}"
  22. BorderBrush="{TemplateBinding BorderBrush}"
  23. BorderThickness="{TemplateBinding BorderThickness}"
  24. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  25. UseLayoutRounding="{TemplateBinding UseLayoutRounding}">
  26. <Path x:Name="ExpandPath" Width="10" Height="10" Margin="{TemplateBinding Padding}"
  27. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  28. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  29. Data="{StaticResource TreeArrow}"
  30. Fill="{StaticResource TreeViewItem.TreeArrow.Static.Fill}"
  31. RenderTransformOrigin="0.5,0.5" Stretch="Uniform"
  32. Stroke="{StaticResource TreeViewItem.TreeArrow.Static.Stroke}"
  33. StrokeThickness="0">
  34. <Path.RenderTransform>
  35. <TransformGroup>
  36. <ScaleTransform />
  37. <SkewTransform />
  38. <RotateTransform />
  39. <TranslateTransform />
  40. </TransformGroup>
  41. </Path.RenderTransform>
  42. </Path>
  43. <VisualStateManager.VisualStateGroups>
  44. <VisualStateGroup x:Name="CheckStates">
  45. <VisualState x:Name="Checked">
  46. <Storyboard>
  47. <DoubleAnimation Duration="0:0:0.2" Storyboard.TargetName="ExpandPath"
  48. Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)"
  49. To="90" />
  50. </Storyboard>
  51. </VisualState>
  52. <VisualState x:Name="Unchecked">
  53. <Storyboard>
  54. <DoubleAnimation Duration="0:0:0.2" Storyboard.TargetName="ExpandPath"
  55. Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)"
  56. To="0" />
  57. </Storyboard>
  58. </VisualState>
  59. </VisualStateGroup>
  60. </VisualStateManager.VisualStateGroups>
  61. </Border>
  62. <ControlTemplate.Triggers>
  63. <Trigger Property="IsMouseOver" Value="True">
  64. <Setter TargetName="Bd" Property="Cursor" Value="Hand" />
  65. <Setter TargetName="Bd" Property="Background" Value="#F3F3F3" />
  66. </Trigger>
  67. </ControlTemplate.Triggers>
  68. </ControlTemplate>
  69. </Setter.Value>
  70. </Setter>
  71. </Style>
  72. </ResourceDictionary>