ButtonStyle.xaml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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="TitleBarButtonStyle" TargetType="{x:Type Button}">
  7. <Setter Property="Background" Value="Transparent"></Setter>
  8. <Setter Property="BorderThickness" Value="0" />
  9. <Setter Property="HorizontalContentAlignment" Value="Center" />
  10. <Setter Property="VerticalContentAlignment" Value="Center" />
  11. <Setter Property="Padding" Value="0" />
  12. <Setter Property="Width" Value="30" />
  13. <Setter Property="Height" Value="30" />
  14. <Setter Property="IsTabStop" Value="False" />
  15. <Setter Property="Template">
  16. <Setter.Value>
  17. <ControlTemplate TargetType="{x:Type Button}">
  18. <Border
  19. x:Name="border"
  20. Background="{TemplateBinding Background}"
  21. BorderBrush="{TemplateBinding BorderBrush}"
  22. BorderThickness="{TemplateBinding BorderThickness}"
  23. SnapsToDevicePixels="true">
  24. <ContentPresenter
  25. x:Name="contentPresenter"
  26. Margin="{TemplateBinding Padding}"
  27. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  28. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  29. Focusable="False"
  30. RecognizesAccessKey="True"
  31. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  32. </Border>
  33. <ControlTemplate.Triggers>
  34. <Trigger Property="IsMouseOver" Value="true">
  35. <Setter TargetName="border" Property="Background" Value="#2894FF" />
  36. <Setter TargetName="border" Property="BorderBrush" Value="#2894FF" />
  37. </Trigger>
  38. <Trigger Property="IsPressed" Value="true">
  39. <Setter TargetName="border" Property="Background" Value="#2894FF" />
  40. <Setter TargetName="border" Property="BorderBrush" Value="#FFFFFF" />
  41. </Trigger>
  42. <Trigger Property="IsEnabled" Value="false">
  43. <Setter TargetName="contentPresenter" Property="TextElement.Foreground" Value="#FFE2E3E6" />
  44. <Setter TargetName="contentPresenter" Property="Opacity" Value="0.5" />
  45. </Trigger>
  46. </ControlTemplate.Triggers>
  47. </ControlTemplate>
  48. </Setter.Value>
  49. </Setter>
  50. </Style>
  51. <Style x:Key="TransparentButtonStyle" TargetType="{x:Type Button}">
  52. <Setter Property="Background" Value="Transparent"/>
  53. <Setter Property="BorderBrush" Value="Transparent"/>
  54. <Setter Property="Foreground" Value="White"/>
  55. <Setter Property="Template">
  56. <Setter.Value>
  57. <ControlTemplate TargetType="{x:Type Button}">
  58. <Border x:Name="border"
  59. Background="{TemplateBinding Background}"
  60. BorderBrush="{TemplateBinding BorderBrush}"
  61. BorderThickness="{TemplateBinding BorderThickness}">
  62. <ContentPresenter HorizontalAlignment="Center"
  63. VerticalAlignment="Center"/>
  64. </Border>
  65. <ControlTemplate.Triggers>
  66. <Trigger Property="IsMouseOver" Value="True">
  67. <Setter TargetName="border" Property="Background" Value="#4C000000"/>
  68. <Setter TargetName="border" Property="BorderBrush" Value="White"/>
  69. </Trigger>
  70. <Trigger Property="IsPressed" Value="True">
  71. <Setter TargetName="border" Property="Background" Value="#80000000"/>
  72. <Setter TargetName="border" Property="BorderBrush" Value="White"/>
  73. </Trigger>
  74. </ControlTemplate.Triggers>
  75. </ControlTemplate>
  76. </Setter.Value>
  77. </Setter>
  78. </Style>
  79. <Style x:Key="FocusVisual">
  80. <Setter Property="Control.Template">
  81. <Setter.Value>
  82. <ControlTemplate>
  83. <Rectangle Margin="2" StrokeDashArray="1 2" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" SnapsToDevicePixels="true" StrokeThickness="1"/>
  84. </ControlTemplate>
  85. </Setter.Value>
  86. </Setter>
  87. </Style>
  88. <Style x:Key="ButtonStyle" TargetType="{x:Type Button}">
  89. <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
  90. <Setter Property="Background" Value="{StaticResource Button.Static.Background}"/>
  91. <Setter Property="BorderBrush" Value="{StaticResource Button.Static.Border}"/>
  92. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
  93. <Setter Property="BorderThickness" Value="1"/>
  94. <Setter Property="HorizontalContentAlignment" Value="Center"/>
  95. <Setter Property="VerticalContentAlignment" Value="Center"/>
  96. <Setter Property="Padding" Value="1"/>
  97. <Setter Property="Template">
  98. <Setter.Value>
  99. <ControlTemplate TargetType="{x:Type Button}">
  100. <Border x:Name="border"
  101. Background="{TemplateBinding Background}"
  102. BorderBrush="{TemplateBinding BorderBrush}"
  103. BorderThickness="{TemplateBinding BorderThickness}"
  104. SnapsToDevicePixels="true">
  105. <ContentPresenter x:Name="contentPresenter"
  106. Focusable="False"
  107. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  108. Margin="{TemplateBinding Padding}"
  109. RecognizesAccessKey="True"
  110. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  111. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  112. </Border>
  113. <ControlTemplate.Triggers>
  114. <Trigger Property="IsDefaulted" Value="true">
  115. <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
  116. </Trigger>
  117. <Trigger Property="IsMouseOver" Value="true">
  118. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.MouseOver.Background}"/>
  119. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.MouseOver.Border}"/>
  120. </Trigger>
  121. <Trigger Property="IsPressed" Value="true">
  122. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
  123. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
  124. </Trigger>
  125. <Trigger Property="IsEnabled" Value="false">
  126. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Enabled.Foreground}"/>
  127. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Enabled.Foreground}"/>
  128. <Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{StaticResource Text.Enabled.Foreground}"/>
  129. <Setter Property="Opacity" Value="0.5"></Setter>
  130. </Trigger>
  131. <Trigger Property="IsEnabled" Value="True">
  132. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Enabled.Foreground}"/>
  133. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Enabled.Foreground}"/>
  134. <Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{StaticResource Text.Enabled.Foreground}"/>
  135. </Trigger>
  136. </ControlTemplate.Triggers>
  137. </ControlTemplate>
  138. </Setter.Value>
  139. </Setter>
  140. </Style>
  141. <Style x:Key="LightButtonStyle" TargetType="{x:Type Button}">
  142. <Setter Property="Template">
  143. <Setter.Value>
  144. <ControlTemplate TargetType="{x:Type Button}">
  145. <Border x:Name="border"
  146. Background="{TemplateBinding Background}"
  147. BorderBrush="{TemplateBinding BorderBrush}"
  148. BorderThickness="{TemplateBinding BorderThickness}"
  149. SnapsToDevicePixels="true">
  150. <ContentPresenter x:Name="contentPresenter"
  151. Focusable="False"
  152. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  153. Margin="{TemplateBinding Padding}"
  154. RecognizesAccessKey="True"
  155. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  156. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  157. </Border>
  158. <ControlTemplate.Triggers>
  159. <Trigger Property="IsDefaulted" Value="true">
  160. <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
  161. </Trigger>
  162. <Trigger Property="IsMouseOver" Value="true">
  163. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
  164. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
  165. </Trigger>
  166. <Trigger Property="IsPressed" Value="true">
  167. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
  168. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
  169. </Trigger>
  170. <Trigger Property="IsEnabled" Value="false">
  171. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Disabled.Background}"/>
  172. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Disabled.Border}"/>
  173. <Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{StaticResource Button.Disabled.Foreground}"/>
  174. </Trigger>
  175. </ControlTemplate.Triggers>
  176. </ControlTemplate>
  177. </Setter.Value>
  178. </Setter>
  179. </Style>
  180. <Style x:Key="RoundButtonStyle" TargetType="{x:Type Button}">
  181. <Setter Property="Template">
  182. <Setter.Value>
  183. <ControlTemplate TargetType="{x:Type Button}">
  184. <Border x:Name="border"
  185. Background="{TemplateBinding Background}"
  186. BorderBrush="{TemplateBinding BorderBrush}"
  187. BorderThickness="{TemplateBinding BorderThickness}"
  188. SnapsToDevicePixels="true" CornerRadius="5">
  189. <ContentPresenter x:Name="contentPresenter"
  190. Focusable="False"
  191. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  192. Margin="{TemplateBinding Padding}"
  193. RecognizesAccessKey="True"
  194. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  195. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  196. </Border>
  197. <ControlTemplate.Triggers>
  198. <Trigger Property="IsDefaulted" Value="true">
  199. <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
  200. </Trigger>
  201. <Trigger Property="IsMouseOver" Value="true">
  202. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
  203. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
  204. </Trigger>
  205. <Trigger Property="IsPressed" Value="true">
  206. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
  207. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
  208. </Trigger>
  209. </ControlTemplate.Triggers>
  210. </ControlTemplate>
  211. </Setter.Value>
  212. </Setter>
  213. </Style>
  214. <Style x:Key="RoundMarginButtonStyle" TargetType="{x:Type Button}">
  215. <Setter Property="Template">
  216. <Setter.Value>
  217. <ControlTemplate TargetType="{x:Type Button}">
  218. <Border x:Name="border"
  219. Background="{TemplateBinding Background}"
  220. BorderBrush="{TemplateBinding BorderBrush}"
  221. BorderThickness="{TemplateBinding BorderThickness}"
  222. SnapsToDevicePixels="true" CornerRadius="4" Margin="0,5">
  223. <ContentPresenter x:Name="contentPresenter"
  224. Focusable="False"
  225. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  226. Margin="{TemplateBinding Padding}"
  227. RecognizesAccessKey="True"
  228. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  229. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  230. </Border>
  231. <ControlTemplate.Triggers>
  232. <Trigger Property="IsDefaulted" Value="true">
  233. <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
  234. </Trigger>
  235. <Trigger Property="IsMouseOver" Value="true">
  236. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
  237. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
  238. </Trigger>
  239. <Trigger Property="IsPressed" Value="true">
  240. <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
  241. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
  242. </Trigger>
  243. </ControlTemplate.Triggers>
  244. </ControlTemplate>
  245. </Setter.Value>
  246. </Setter>
  247. </Style>
  248. <Style x:Key="ImagePathButtonStyle" TargetType="{x:Type Button}">
  249. <Setter Property="Background" Value="Transparent" />
  250. <Setter Property="Foreground" Value="Black" />
  251. <Setter Property="BorderBrush" Value="#5A000000" />
  252. <Setter Property="BorderThickness" Value="1" />
  253. <Setter Property="Padding" Value="10" />
  254. <Setter Property="Template">
  255. <Setter.Value>
  256. <ControlTemplate TargetType="{x:Type Button}">
  257. <Border Background="{TemplateBinding Background}"
  258. BorderBrush="{TemplateBinding BorderBrush}"
  259. BorderThickness="{TemplateBinding BorderThickness}"
  260. x:Name="border">
  261. <ContentPresenter HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
  262. </Border>
  263. <ControlTemplate.Triggers>
  264. <Trigger Property="IsMouseOver" Value="True">
  265. <Setter TargetName="border" Property="Background" Value="#1A000000" />
  266. </Trigger>
  267. <Trigger Property="IsPressed" Value="True">
  268. <Setter TargetName="border" Property="Background" Value="#3A000000" />
  269. </Trigger>
  270. <Trigger Property="IsEnabled" Value="False">
  271. <Setter Property="Opacity" Value="0.5" />
  272. </Trigger>
  273. </ControlTemplate.Triggers>
  274. </ControlTemplate>
  275. </Setter.Value>
  276. </Setter>
  277. </Style>
  278. </ResourceDictionary>