DefaultToggleButton.xaml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:WPF.UI="clr-namespace:CustomUI">
  4. <SolidColorBrush x:Key="Button.Static.Background" Color="#FFDBB377" />
  5. <SolidColorBrush x:Key="Button.Static.Border" Color="#FF707070" />
  6. <SolidColorBrush x:Key="Button.MouseOver.Background" Color="#FFBEE6FD" />
  7. <SolidColorBrush x:Key="Button.MouseOver.Border" Color="#FF3C7FB1" />
  8. <SolidColorBrush x:Key="Button.Pressed.Background" Color="#FFC4E5F6" />
  9. <SolidColorBrush x:Key="Button.Pressed.Border" Color="#FF2C628B" />
  10. <SolidColorBrush x:Key="Button.Disabled.Background" Color="#FFF4F4F4" />
  11. <SolidColorBrush x:Key="Button.Disabled.Border" Color="#FFADB2B5" />
  12. <SolidColorBrush x:Key="Button.Disabled.Foreground" Color="#FF838383" />
  13. <SolidColorBrush x:Key="Button.Checked.Foreground" Color="#FF76E8A6" />
  14. <Style TargetType="{x:Type WPF.UI:FlatToggleButton}">
  15. <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  16. <Setter Property="Background" Value="{StaticResource Button.Pressed.Background}" />
  17. <Setter Property="BorderBrush" Value="{StaticResource Button.Static.Border}" />
  18. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
  19. <Setter Property="BorderThickness" Value="0" />
  20. <Setter Property="HorizontalContentAlignment" Value="Center" />
  21. <Setter Property="VerticalContentAlignment" Value="Center" />
  22. <Setter Property="Padding" Value="0" />
  23. <Setter Property="Width" Value="43" />
  24. <Setter Property="Height" Value="20" />
  25. <Setter Property="Template">
  26. <Setter.Value>
  27. <ControlTemplate TargetType="{x:Type WPF.UI:FlatToggleButton}">
  28. <Grid>
  29. <Border x:Name="border"
  30. Background="{StaticResource Button.Pressed.Background}"
  31. BorderBrush="{TemplateBinding BorderBrush}"
  32. BorderThickness="{TemplateBinding BorderThickness}"
  33. CornerRadius="10" SnapsToDevicePixels="true" UseLayoutRounding="True" />
  34. <Border x:Name="InnerBd" Width="15" Height="15" Margin="3,0"
  35. HorizontalAlignment="Left" VerticalAlignment="Center" Background="White" CornerRadius="100"
  36. RenderTransformOrigin="0.5,0.5">
  37. <Border.RenderTransform>
  38. <TransformGroup>
  39. <ScaleTransform />
  40. <SkewTransform />
  41. <RotateTransform />
  42. <TranslateTransform />
  43. </TransformGroup>
  44. </Border.RenderTransform>
  45. </Border>
  46. <VisualStateManager.VisualStateGroups>
  47. <VisualStateGroup x:Name="CheckStates">
  48. <VisualState x:Name="Checked">
  49. <Storyboard>
  50. <DoubleAnimationUsingKeyFrames Storyboard.TargetName="InnerBd" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
  51. <EasingDoubleKeyFrame KeyTime="0" Value="0">
  52. <EasingDoubleKeyFrame.EasingFunction>
  53. <CubicEase EasingMode="EaseOut" />
  54. </EasingDoubleKeyFrame.EasingFunction>
  55. </EasingDoubleKeyFrame>
  56. <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="22">
  57. <EasingDoubleKeyFrame.EasingFunction>
  58. <CubicEase EasingMode="EaseOut" />
  59. </EasingDoubleKeyFrame.EasingFunction>
  60. </EasingDoubleKeyFrame>
  61. </DoubleAnimationUsingKeyFrames>
  62. <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="border" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)">
  63. <EasingColorKeyFrame KeyTime="0:0:0" Value="#FFC4E5F6">
  64. <EasingColorKeyFrame.EasingFunction>
  65. <CircleEase EasingMode="EaseOut" />
  66. </EasingColorKeyFrame.EasingFunction>
  67. </EasingColorKeyFrame>
  68. <EasingColorKeyFrame KeyTime="0:0:0.2" Value="#FF3399FF">
  69. <EasingColorKeyFrame.EasingFunction>
  70. <CircleEase EasingMode="EaseOut" />
  71. </EasingColorKeyFrame.EasingFunction>
  72. </EasingColorKeyFrame>
  73. </ColorAnimationUsingKeyFrames>
  74. </Storyboard>
  75. </VisualState>
  76. <VisualState x:Name="Unchecked">
  77. <Storyboard>
  78. <DoubleAnimationUsingKeyFrames Storyboard.TargetName="InnerBd" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
  79. <EasingDoubleKeyFrame KeyTime="0" Value="22">
  80. <EasingDoubleKeyFrame.EasingFunction>
  81. <CubicEase EasingMode="EaseIn" />
  82. </EasingDoubleKeyFrame.EasingFunction>
  83. </EasingDoubleKeyFrame>
  84. <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0">
  85. <EasingDoubleKeyFrame.EasingFunction>
  86. <CubicEase EasingMode="EaseIn" />
  87. </EasingDoubleKeyFrame.EasingFunction>
  88. </EasingDoubleKeyFrame>
  89. </DoubleAnimationUsingKeyFrames>
  90. <ColorAnimation BeginTime="00:00:00" Duration="0:0:0.2" From="#FF3399FF"
  91. Storyboard.TargetName="border"
  92. Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)"
  93. To="#FFC4E5F6" />
  94. </Storyboard>
  95. </VisualState>
  96. </VisualStateGroup>
  97. </VisualStateManager.VisualStateGroups>
  98. </Grid>
  99. </ControlTemplate>
  100. </Setter.Value>
  101. </Setter>
  102. </Style>
  103. </ResourceDictionary>