ToggleButtonStyle.xaml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  3. <ResourceDictionary.MergedDictionaries>
  4. <ResourceDictionary Source="../Themes/Global.xaml"></ResourceDictionary>
  5. </ResourceDictionary.MergedDictionaries>
  6. <Style x:Key="FocusVisual">
  7. <Setter Property="Control.Template">
  8. <Setter.Value>
  9. <ControlTemplate>
  10. <Rectangle Margin="2" StrokeDashArray="1 2" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" SnapsToDevicePixels="true" StrokeThickness="1"/>
  11. </ControlTemplate>
  12. </Setter.Value>
  13. </Setter>
  14. </Style>
  15. <Style x:Key="ToggleButtonStyle" TargetType="{x:Type ToggleButton}">
  16. <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
  17. <Setter Property="Background" Value="{StaticResource Button.Static.Background}"/>
  18. <Setter Property="BorderBrush" Value="{StaticResource Button.Static.Border}"/>
  19. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
  20. <Setter Property="BorderThickness" Value="1"/>
  21. <Setter Property="HorizontalContentAlignment" Value="Center"/>
  22. <Setter Property="VerticalContentAlignment" Value="Center"/>
  23. <Setter Property="Padding" Value="1"/>
  24. <Setter Property="Template">
  25. <Setter.Value>
  26. <ControlTemplate TargetType="{x:Type ToggleButton}">
  27. <Border x:Name="border"
  28. Background="{TemplateBinding Background}"
  29. BorderBrush="{TemplateBinding BorderBrush}"
  30. BorderThickness="{TemplateBinding BorderThickness}"
  31. SnapsToDevicePixels="true">
  32. <ContentPresenter x:Name="contentPresenter"
  33. Focusable="False"
  34. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  35. Margin="{TemplateBinding Padding}"
  36. RecognizesAccessKey="True"
  37. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  38. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  39. </Border>
  40. <ControlTemplate.Triggers>
  41. <Trigger Property="Button.IsDefaulted" Value="true">
  42. <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
  43. </Trigger>
  44. <Trigger Property="IsMouseOver" Value="true">
  45. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
  46. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
  47. </Trigger>
  48. <Trigger Property="IsPressed" Value="true">
  49. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
  50. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
  51. </Trigger>
  52. <Trigger Property="IsEnabled" Value="false">
  53. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Disabled.Background}"/>
  54. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Disabled.Border}"/>
  55. <Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{StaticResource Button.Disabled.Foreground}"/>
  56. </Trigger>
  57. <Trigger Property="IsChecked" Value="True">
  58. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
  59. </Trigger>
  60. </ControlTemplate.Triggers>
  61. </ControlTemplate>
  62. </Setter.Value>
  63. </Setter>
  64. </Style>
  65. <Style x:Key="RoundToggleButtonStyle" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource ToggleButtonStyle}">
  66. <Setter Property="Template">
  67. <Setter.Value>
  68. <ControlTemplate TargetType="{x:Type ToggleButton}">
  69. <Border x:Name="border"
  70. Background="{TemplateBinding Background}"
  71. BorderBrush="{TemplateBinding BorderBrush}"
  72. BorderThickness="{TemplateBinding BorderThickness}"
  73. SnapsToDevicePixels="true" CornerRadius="5">
  74. <ContentPresenter x:Name="contentPresenter"
  75. Focusable="False"
  76. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  77. Margin="{TemplateBinding Padding}"
  78. RecognizesAccessKey="True"
  79. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  80. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  81. </Border>
  82. <ControlTemplate.Triggers>
  83. <Trigger Property="Button.IsDefaulted" Value="true">
  84. <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
  85. </Trigger>
  86. <Trigger Property="IsMouseOver" Value="true">
  87. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
  88. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
  89. </Trigger>
  90. <Trigger Property="IsPressed" Value="true">
  91. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
  92. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
  93. </Trigger>
  94. <Trigger Property="IsEnabled" Value="false">
  95. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Disabled.Background}"/>
  96. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Disabled.Border}"/>
  97. <Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{StaticResource Button.Disabled.Foreground}"/>
  98. </Trigger>
  99. <Trigger Property="IsChecked" Value="True">
  100. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
  101. </Trigger>
  102. </ControlTemplate.Triggers>
  103. </ControlTemplate>
  104. </Setter.Value>
  105. </Setter>
  106. </Style>
  107. <Style x:Key="ToggleButtonSwitchStyle" TargetType="{x:Type ToggleButton}">
  108. <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
  109. <Setter Property="Background" Value="{StaticResource Button.Static.Background}"/>
  110. <Setter Property="BorderBrush" Value="{StaticResource Button.Static.Border}"/>
  111. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
  112. <Setter Property="BorderThickness" Value="1"/>
  113. <Setter Property="HorizontalContentAlignment" Value="Center"/>
  114. <Setter Property="VerticalContentAlignment" Value="Center"/>
  115. <Setter Property="Padding" Value="1"/>
  116. <Setter Property="Template">
  117. <Setter.Value>
  118. <ControlTemplate TargetType="{x:Type ToggleButton}">
  119. <Border x:Name="border"
  120. Background="{TemplateBinding Background}"
  121. BorderBrush="{TemplateBinding BorderBrush}"
  122. BorderThickness="{TemplateBinding BorderThickness}"
  123. SnapsToDevicePixels="true">
  124. <Grid>
  125. <Path x:Name="uncheckRound" Stroke="#99000000" StrokeThickness="2">
  126. <Path.Data>
  127. <GeometryGroup >
  128. <RectangleGeometry Rect="0,0,38,18" RadiusX="10" RadiusY="10"></RectangleGeometry>
  129. </GeometryGroup>
  130. </Path.Data>
  131. </Path>
  132. <Path x:Name="uncheckCircle" Fill="#99000000">
  133. <Path.Data>
  134. <GeometryGroup >
  135. <EllipseGeometry RadiusX="6" RadiusY="6" Center="11,9"></EllipseGeometry>
  136. </GeometryGroup>
  137. </Path.Data>
  138. </Path>
  139. <Path x:Name="checkCircle" Fill="White" Visibility="Collapsed">
  140. <Path.Data>
  141. <GeometryGroup >
  142. <EllipseGeometry RadiusX="6" RadiusY="6" Center="27,9"></EllipseGeometry>
  143. </GeometryGroup>
  144. </Path.Data>
  145. </Path>
  146. <ContentPresenter x:Name="contentPresenter"
  147. Focusable="False"
  148. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  149. Margin="{TemplateBinding Padding}"
  150. RecognizesAccessKey="True"
  151. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  152. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  153. </Grid>
  154. </Border>
  155. <ControlTemplate.Triggers>
  156. <Trigger Property="Button.IsDefaulted" Value="true">
  157. <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
  158. </Trigger>
  159. <Trigger Property="IsMouseOver" Value="true">
  160. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
  161. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
  162. </Trigger>
  163. <Trigger Property="IsPressed" Value="true">
  164. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
  165. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
  166. </Trigger>
  167. <Trigger Property="IsEnabled" Value="false">
  168. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Disabled.Background}"/>
  169. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Disabled.Border}"/>
  170. <Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{StaticResource Button.Disabled.Foreground}"/>
  171. </Trigger>
  172. <Trigger Property="IsChecked" Value="True">
  173. <Setter Property="Fill" TargetName="uncheckRound" Value="#1460F3"></Setter>
  174. <Setter Property="Visibility" TargetName="uncheckCircle" Value="Collapsed"></Setter>
  175. <Setter Property="Visibility" TargetName="checkCircle" Value="Visible"></Setter>
  176. <Setter Property="Stroke" TargetName="uncheckRound" Value="#1460F3"></Setter>
  177. </Trigger>
  178. </ControlTemplate.Triggers>
  179. </ControlTemplate>
  180. </Setter.Value>
  181. </Setter>
  182. </Style>
  183. <Style x:Key="RoundMarginToggleButtonStyle" TargetType="{x:Type ToggleButton}">
  184. <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
  185. <Setter Property="Background" Value="{StaticResource Button.Static.Background}"/>
  186. <Setter Property="BorderBrush" Value="{StaticResource Button.Static.Border}"/>
  187. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
  188. <Setter Property="BorderThickness" Value="1"/>
  189. <Setter Property="HorizontalContentAlignment" Value="Center"/>
  190. <Setter Property="VerticalContentAlignment" Value="Center"/>
  191. <Setter Property="Padding" Value="1"/>
  192. <Setter Property="Template">
  193. <Setter.Value>
  194. <ControlTemplate TargetType="{x:Type ToggleButton}">
  195. <Border x:Name="border" CornerRadius="5" Margin="0,5"
  196. Background="{TemplateBinding Background}"
  197. BorderBrush="{TemplateBinding BorderBrush}"
  198. BorderThickness="{TemplateBinding BorderThickness}"
  199. SnapsToDevicePixels="true">
  200. <ContentPresenter x:Name="contentPresenter"
  201. Focusable="False"
  202. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  203. Margin="{TemplateBinding Padding}"
  204. RecognizesAccessKey="True"
  205. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  206. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  207. </Border>
  208. <ControlTemplate.Triggers>
  209. <Trigger Property="Button.IsDefaulted" Value="true">
  210. <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
  211. </Trigger>
  212. <Trigger Property="IsMouseOver" Value="true">
  213. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
  214. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
  215. </Trigger>
  216. <Trigger Property="IsPressed" Value="true">
  217. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
  218. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
  219. </Trigger>
  220. <Trigger Property="IsEnabled" Value="false">
  221. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Disabled.Background}"/>
  222. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Disabled.Border}"/>
  223. <Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{StaticResource Button.Disabled.Foreground}"/>
  224. </Trigger>
  225. <Trigger Property="IsChecked" Value="True">
  226. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
  227. </Trigger>
  228. </ControlTemplate.Triggers>
  229. </ControlTemplate>
  230. </Setter.Value>
  231. </Setter>
  232. </Style>
  233. </ResourceDictionary>