Button.xaml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  2. <ResourceDictionary.MergedDictionaries>
  3. <ResourceDictionary Source="BaseStyle.xaml" />
  4. </ResourceDictionary.MergedDictionaries>
  5. <!-- 按钮 源码行数:2782-3171 -->
  6. <!-- ButtonBase基样式 -->
  7. <Style
  8. x:Key="ButtonBaseBaseStyle"
  9. BasedOn="{StaticResource BaseStyle}"
  10. TargetType="{x:Type ButtonBase}">
  11. <Setter Property="Height" Value="{DynamicResource DefaultControlHeight}" />
  12. <Setter Property="Foreground" Value="{DynamicResource ButtonForeground}" />
  13. <Setter Property="Padding" Value="{DynamicResource DefaultControlPadding}" />
  14. <Setter Property="BorderThickness" Value="1" />
  15. <Setter Property="Cursor" Value="Hand" />
  16. <Setter Property="HorizontalAlignment" Value="Center" />
  17. <Setter Property="VerticalAlignment" Value="Center" />
  18. <Setter Property="HorizontalContentAlignment" Value="Center" />
  19. <Setter Property="VerticalContentAlignment" Value="Center" />
  20. </Style>
  21. <!-- Button基样式 -->
  22. <Style
  23. x:Key="ButtonBaseStyle"
  24. BasedOn="{StaticResource ButtonBaseBaseStyle}"
  25. TargetType="{x:Type Button}">
  26. <Setter Property="Template">
  27. <Setter.Value>
  28. <ControlTemplate TargetType="{x:Type Button}">
  29. <Grid>
  30. <Border
  31. x:Name="border"
  32. Padding="0"
  33. Background="{TemplateBinding Background}"
  34. BorderBrush="{TemplateBinding BorderBrush}"
  35. BorderThickness="{TemplateBinding BorderThickness}"
  36. CornerRadius="5"
  37. SnapsToDevicePixels="true">
  38. <!-- 点击时显示 -->
  39. <Grid x:Name="PressedLayer" Visibility="Collapsed">
  40. <Rectangle
  41. Height="3"
  42. VerticalAlignment="Top"
  43. Fill="#1F000000"
  44. RadiusX="4"
  45. RadiusY="4">
  46. <Rectangle.Effect>
  47. <BlurEffect Radius="5" />
  48. </Rectangle.Effect>
  49. </Rectangle>
  50. <Border
  51. BorderBrush="#1F000000"
  52. BorderThickness="1,0"
  53. CornerRadius="4">
  54. <Border.Effect>
  55. <BlurEffect Radius="3" />
  56. </Border.Effect>
  57. </Border>
  58. </Grid>
  59. </Border>
  60. <Border BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="5">
  61. <ContentPresenter
  62. Margin="{TemplateBinding Padding}"
  63. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  64. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  65. RecognizesAccessKey="True"
  66. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  67. </Border>
  68. <!-- 禁用时显示 -->
  69. <Rectangle
  70. x:Name="EnabledLayer"
  71. Fill="#4CFFFFFF"
  72. RadiusX="4"
  73. RadiusY="4"
  74. Visibility="Collapsed" />
  75. </Grid>
  76. <ControlTemplate.Triggers>
  77. <Trigger Property="IsPressed" Value="true">
  78. <Setter TargetName="PressedLayer" Property="Visibility" Value="Visible" />
  79. <Setter TargetName="border" Property="BorderBrush" Value="#80cccccc" />
  80. </Trigger>
  81. <Trigger Property="IsEnabled" Value="false">
  82. <Setter TargetName="EnabledLayer" Property="Visibility" Value="Visible" />
  83. </Trigger>
  84. </ControlTemplate.Triggers>
  85. </ControlTemplate>
  86. </Setter.Value>
  87. </Setter>
  88. </Style>
  89. <!-- ToggleButton基样式 -->
  90. <Style
  91. x:Key="ToggleButtonBaseStyle"
  92. BasedOn="{StaticResource ButtonBaseBaseStyle}"
  93. TargetType="{x:Type ToggleButton}">
  94. <Setter Property="Template">
  95. <Setter.Value>
  96. <ControlTemplate TargetType="{x:Type ToggleButton}">
  97. <Grid>
  98. <Border
  99. x:Name="border"
  100. Padding="0"
  101. Background="{TemplateBinding Background}"
  102. BorderBrush="{TemplateBinding BorderBrush}"
  103. BorderThickness="{TemplateBinding BorderThickness}"
  104. CornerRadius="5"
  105. SnapsToDevicePixels="true">
  106. <!-- 点下时显示 -->
  107. <Grid x:Name="CheckedLayer" Visibility="Collapsed">
  108. <Rectangle
  109. Height="3"
  110. VerticalAlignment="Top"
  111. Fill="#1F000000"
  112. RadiusX="5"
  113. RadiusY="5">
  114. <Rectangle.Effect>
  115. <BlurEffect Radius="5" />
  116. </Rectangle.Effect>
  117. </Rectangle>
  118. <Border
  119. BorderBrush="#1F000000"
  120. BorderThickness="1,0"
  121. CornerRadius="5">
  122. <Border.Effect>
  123. <BlurEffect Radius="3" />
  124. </Border.Effect>
  125. </Border>
  126. </Grid>
  127. </Border>
  128. <Border BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="5">
  129. <ContentPresenter
  130. Margin="{TemplateBinding Padding}"
  131. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  132. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  133. RecognizesAccessKey="True"
  134. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  135. </Border>
  136. <!-- 禁用时显示 -->
  137. <Rectangle
  138. x:Name="EnabledLayer"
  139. Fill="#4CFFFFFF"
  140. RadiusX="4"
  141. RadiusY="4"
  142. Visibility="Collapsed" />
  143. </Grid>
  144. <ControlTemplate.Triggers>
  145. <Trigger Property="IsChecked" Value="true">
  146. <Setter TargetName="CheckedLayer" Property="Visibility" Value="Visible" />
  147. <Setter TargetName="border" Property="BorderBrush" Value="#80cccccc" />
  148. </Trigger>
  149. <Trigger Property="IsEnabled" Value="false">
  150. <Setter TargetName="EnabledLayer" Property="Visibility" Value="Visible" />
  151. </Trigger>
  152. </ControlTemplate.Triggers>
  153. </ControlTemplate>
  154. </Setter.Value>
  155. </Setter>
  156. </Style>
  157. <!-- Button -->
  158. <Style
  159. x:Key="btn"
  160. BasedOn="{StaticResource ButtonBaseStyle}"
  161. TargetType="{x:Type Button}">
  162. <Setter Property="Background" Value="{DynamicResource Background-Default1}" />
  163. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush-Default1}" />
  164. <Setter Property="Foreground" Value="{DynamicResource Foreground-Default}" />
  165. <Style.Triggers>
  166. <Trigger Property="IsMouseOver" Value="True">
  167. <Setter Property="Background" Value="#e6e6e6" />
  168. <Setter Property="BorderBrush" Value="#adadad" />
  169. </Trigger>
  170. </Style.Triggers>
  171. </Style>
  172. <Style
  173. x:Key="btn-primary"
  174. BasedOn="{StaticResource ButtonBaseStyle}"
  175. TargetType="{x:Type Button}">
  176. <Setter Property="Background" Value="{DynamicResource Background-Primary1}" />
  177. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush-Primary1}" />
  178. <Style.Triggers>
  179. <Trigger Property="IsMouseOver" Value="True">
  180. <Setter Property="Background" Value="#3071a9" />
  181. <Setter Property="BorderBrush" Value="#285e8e" />
  182. </Trigger>
  183. </Style.Triggers>
  184. </Style>
  185. <Style
  186. x:Key="btn-success"
  187. BasedOn="{StaticResource ButtonBaseStyle}"
  188. TargetType="{x:Type Button}">
  189. <Setter Property="Background" Value="{DynamicResource Background-Success1}" />
  190. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush-Success1}" />
  191. <Style.Triggers>
  192. <Trigger Property="IsMouseOver" Value="True">
  193. <Setter Property="Background" Value="#449d44" />
  194. <Setter Property="BorderBrush" Value="#398439" />
  195. </Trigger>
  196. </Style.Triggers>
  197. </Style>
  198. <Style
  199. x:Key="btn-info"
  200. BasedOn="{StaticResource ButtonBaseStyle}"
  201. TargetType="{x:Type Button}">
  202. <Setter Property="Background" Value="{DynamicResource Background-Info1}" />
  203. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush-Info1}" />
  204. <Style.Triggers>
  205. <Trigger Property="IsMouseOver" Value="True">
  206. <Setter Property="Background" Value="#31b0d5" />
  207. <Setter Property="BorderBrush" Value="#269abc" />
  208. </Trigger>
  209. </Style.Triggers>
  210. </Style>
  211. <Style
  212. x:Key="btn-warning"
  213. BasedOn="{StaticResource ButtonBaseStyle}"
  214. TargetType="{x:Type Button}">
  215. <Setter Property="Background" Value="{DynamicResource Background-Warning1}" />
  216. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush-Warning1}" />
  217. <Style.Triggers>
  218. <Trigger Property="IsMouseOver" Value="True">
  219. <Setter Property="Background" Value="#ec971f" />
  220. <Setter Property="BorderBrush" Value="#d58512" />
  221. </Trigger>
  222. </Style.Triggers>
  223. </Style>
  224. <Style
  225. x:Key="btn-danger"
  226. BasedOn="{StaticResource ButtonBaseStyle}"
  227. TargetType="{x:Type Button}">
  228. <Setter Property="Background" Value="{DynamicResource Background-Danger1}" />
  229. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush-Danger1}" />
  230. <Style.Triggers>
  231. <Trigger Property="IsMouseOver" Value="True">
  232. <Setter Property="Background" Value="#c9302c" />
  233. <Setter Property="BorderBrush" Value="#ac2925" />
  234. </Trigger>
  235. </Style.Triggers>
  236. </Style>
  237. <!-- ToggleButton -->
  238. <Style BasedOn="{StaticResource ToggleButtonBaseStyle}" TargetType="{x:Type ToggleButton}">
  239. <Setter Property="Background" Value="{DynamicResource Background-Default1}" />
  240. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush-Default1}" />
  241. <Setter Property="Foreground" Value="{DynamicResource Foreground-Default}" />
  242. <Style.Triggers>
  243. <Trigger Property="IsMouseOver" Value="True">
  244. <Setter Property="Background" Value="#e6e6e6" />
  245. <Setter Property="BorderBrush" Value="#adadad" />
  246. </Trigger>
  247. </Style.Triggers>
  248. </Style>
  249. <Style
  250. x:Key="tbtn-primary"
  251. BasedOn="{StaticResource ToggleButtonBaseStyle}"
  252. TargetType="{x:Type ToggleButton}">
  253. <Setter Property="Background" Value="{DynamicResource Background-Primary1}" />
  254. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush-Primary1}" />
  255. <Style.Triggers>
  256. <Trigger Property="IsMouseOver" Value="True">
  257. <Setter Property="Background" Value="#3071a9" />
  258. <Setter Property="BorderBrush" Value="#285e8e" />
  259. </Trigger>
  260. </Style.Triggers>
  261. </Style>
  262. <Style
  263. x:Key="tbtn-success"
  264. BasedOn="{StaticResource ToggleButtonBaseStyle}"
  265. TargetType="{x:Type ToggleButton}">
  266. <Setter Property="Background" Value="{DynamicResource Background-Success1}" />
  267. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush-Success1}" />
  268. <Style.Triggers>
  269. <Trigger Property="IsMouseOver" Value="True">
  270. <Setter Property="Background" Value="#449d44" />
  271. <Setter Property="BorderBrush" Value="#398439" />
  272. </Trigger>
  273. </Style.Triggers>
  274. </Style>
  275. <Style
  276. x:Key="tbtn-info"
  277. BasedOn="{StaticResource ToggleButtonBaseStyle}"
  278. TargetType="{x:Type ToggleButton}">
  279. <Setter Property="Background" Value="{DynamicResource Background-Info1}" />
  280. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush-Info1}" />
  281. <Style.Triggers>
  282. <Trigger Property="IsMouseOver" Value="True">
  283. <Setter Property="Background" Value="#31b0d5" />
  284. <Setter Property="BorderBrush" Value="#269abc" />
  285. </Trigger>
  286. </Style.Triggers>
  287. </Style>
  288. <Style
  289. x:Key="tbtn-warning"
  290. BasedOn="{StaticResource ToggleButtonBaseStyle}"
  291. TargetType="{x:Type ToggleButton}">
  292. <Setter Property="Background" Value="{DynamicResource Background-Warning1}" />
  293. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush-Warning1}" />
  294. <Style.Triggers>
  295. <Trigger Property="IsMouseOver" Value="True">
  296. <Setter Property="Background" Value="#ec971f" />
  297. <Setter Property="BorderBrush" Value="#d58512" />
  298. </Trigger>
  299. </Style.Triggers>
  300. </Style>
  301. <Style
  302. x:Key="tbtn-danger"
  303. BasedOn="{StaticResource ToggleButtonBaseStyle}"
  304. TargetType="{x:Type ToggleButton}">
  305. <Setter Property="Background" Value="{DynamicResource Background-Danger1}" />
  306. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush-Danger1}" />
  307. <Style.Triggers>
  308. <Trigger Property="IsMouseOver" Value="True">
  309. <Setter Property="Background" Value="#c9302c" />
  310. <Setter Property="BorderBrush" Value="#ac2925" />
  311. </Trigger>
  312. </Style.Triggers>
  313. </Style>
  314. <Style
  315. x:Key="ToggleButtonStyle"
  316. BasedOn="{StaticResource tbtn-info}"
  317. TargetType="{x:Type ToggleButton}">
  318. <Setter Property="HorizontalAlignment" Value="Right" />
  319. <Setter Property="Margin" Value="0,0,0,0" />
  320. <Style.Triggers>
  321. <Trigger Property="IsChecked" Value="True">
  322. <Setter Property="Content" Value="已启用" />
  323. </Trigger>
  324. <Trigger Property="IsChecked" Value="False">
  325. <Setter Property="Content" Value="已禁用" />
  326. </Trigger>
  327. </Style.Triggers>
  328. </Style>
  329. <Style
  330. x:Key="ToggleButtonStyle2"
  331. BasedOn="{StaticResource tbtn-info}"
  332. TargetType="{x:Type ToggleButton}">
  333. <Setter Property="HorizontalAlignment" Value="Right" />
  334. <Setter Property="Margin" Value="0,0,0,0" />
  335. <Style.Triggers>
  336. <Trigger Property="IsChecked" Value="True">
  337. <Setter Property="Content" Value="是" />
  338. </Trigger>
  339. <Trigger Property="IsChecked" Value="False">
  340. <Setter Property="Content" Value="否" />
  341. </Trigger>
  342. </Style.Triggers>
  343. </Style>
  344. <Style
  345. x:Key="ToggleButtonStyle3"
  346. BasedOn="{StaticResource tbtn-info}"
  347. TargetType="{x:Type ToggleButton}">
  348. <Setter Property="HorizontalAlignment" Value="Right" />
  349. <Setter Property="Margin" Value="0,0,0,0" />
  350. <Style.Triggers>
  351. <Trigger Property="IsChecked" Value="True">
  352. <Setter Property="Content" Value="停止测试" />
  353. </Trigger>
  354. <Trigger Property="IsChecked" Value="False">
  355. <Setter Property="Content" Value="开始测试" />
  356. </Trigger>
  357. </Style.Triggers>
  358. </Style>
  359. </ResourceDictionary>