RadioButtonStyle.xaml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  2. <Style x:Key="OptionMarkFocusVisual">
  3. <Setter Property="Control.Template">
  4. <Setter.Value>
  5. <ControlTemplate>
  6. <Rectangle
  7. Margin="14,0,0,0"
  8. SnapsToDevicePixels="true"
  9. Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
  10. StrokeDashArray="1 2"
  11. StrokeThickness="1" />
  12. </ControlTemplate>
  13. </Setter.Value>
  14. </Setter>
  15. </Style>
  16. <Style x:Key="FocusVisual">
  17. <Setter Property="Control.Template">
  18. <Setter.Value>
  19. <ControlTemplate>
  20. <Rectangle
  21. Margin="2"
  22. SnapsToDevicePixels="true"
  23. Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
  24. StrokeDashArray="1 2"
  25. StrokeThickness="1" />
  26. </ControlTemplate>
  27. </Setter.Value>
  28. </Setter>
  29. </Style>
  30. <SolidColorBrush x:Key="RadioButton.Static.Background" Color="#FFFFFFFF" />
  31. <SolidColorBrush x:Key="RadioButton.Static.Border" Color="#FF707070" />
  32. <SolidColorBrush x:Key="RadioButton.MouseOver.Background" Color="#1A000000" />
  33. <SolidColorBrush x:Key="RadioButton.MouseOver.Border" Color="#FF5593FF" />
  34. <SolidColorBrush x:Key="RadioButton.MouseOver.Glyph" Color="#FFF3F9FF" />
  35. <SolidColorBrush x:Key="RadioButton.Disabled.Background" Color="#00000000" />
  36. <SolidColorBrush x:Key="RadioButton.Disabled.Border" Color="#FFBCBCBC" />
  37. <SolidColorBrush x:Key="RadioButton.Disabled.Glyph" Color="#FF707070" />
  38. <SolidColorBrush x:Key="RadioButton.Pressed.Background" Color="#26000000" />
  39. <SolidColorBrush x:Key="RadioButton.Pressed.Border" Color="#FF3C77DD" />
  40. <SolidColorBrush x:Key="RadioButton.Pressed.Glyph" Color="#1A477EDE" />
  41. <SolidColorBrush x:Key="RadioButton.Static.Glyph" Color="#FF212121" />
  42. <!-- 填充颜色 -->
  43. <SolidColorBrush x:Key="Separator.fill" Color="#1A000000" />
  44. <SolidColorBrush x:Key="MenuIco.fill" Color="#000000" />
  45. <Style x:Key="PageViewRadioBtn" TargetType="{x:Type RadioButton}">
  46. <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
  47. <Setter Property="Background" Value="{StaticResource RadioButton.Static.Background}" />
  48. <Setter Property="BorderBrush" Value="{StaticResource RadioButton.Static.Border}" />
  49. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
  50. <Setter Property="BorderThickness" Value="0" />
  51. <Setter Property="Width" Value="60" />
  52. <Setter Property="Height" Value="80" />
  53. <Setter Property="HorizontalContentAlignment" Value="Center" />
  54. <Setter Property="VerticalContentAlignment" Value="Center" />
  55. <Setter Property="Template">
  56. <Setter.Value>
  57. <ControlTemplate TargetType="{x:Type RadioButton}">
  58. <Grid
  59. x:Name="templateRoot"
  60. Background="Transparent"
  61. SnapsToDevicePixels="True">
  62. <Border
  63. x:Name="radioButtonBorder"
  64. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  65. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  66. Background="{TemplateBinding Background}"
  67. BorderBrush="{TemplateBinding BorderBrush}"
  68. BorderThickness="{TemplateBinding BorderThickness}">
  69. <Rectangle
  70. x:Name="optionMark"
  71. Width="{TemplateBinding Width}"
  72. Height="{TemplateBinding Height}"
  73. Opacity="0" />
  74. </Border>
  75. <ContentPresenter
  76. x:Name="contentPresenter"
  77. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  78. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  79. Focusable="False"
  80. RecognizesAccessKey="True"
  81. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  82. </Grid>
  83. <ControlTemplate.Triggers>
  84. <Trigger Property="HasContent" Value="true">
  85. <Setter Property="FocusVisualStyle" Value="{StaticResource OptionMarkFocusVisual}" />
  86. <Setter Property="Padding" Value="4,-1,0,0" />
  87. </Trigger>
  88. <Trigger Property="IsMouseOver" Value="true">
  89. <Setter TargetName="radioButtonBorder" Property="Background" Value="{StaticResource RadioButton.MouseOver.Background}" />
  90. <Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{StaticResource RadioButton.MouseOver.Border}" />
  91. <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource RadioButton.MouseOver.Glyph}" />
  92. </Trigger>
  93. <Trigger Property="IsEnabled" Value="false">
  94. <Setter TargetName="radioButtonBorder" Property="Background" Value="{StaticResource RadioButton.Disabled.Background}" />
  95. <Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{StaticResource RadioButton.Disabled.Border}" />
  96. <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource RadioButton.Disabled.Glyph}" />
  97. </Trigger>
  98. <Trigger Property="IsPressed" Value="true">
  99. <Setter TargetName="radioButtonBorder" Property="Background" Value="{StaticResource RadioButton.Pressed.Background}" />
  100. <Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{StaticResource RadioButton.Pressed.Border}" />
  101. <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource RadioButton.Pressed.Glyph}" />
  102. </Trigger>
  103. <Trigger Property="IsChecked" Value="true">
  104. <Setter TargetName="optionMark" Property="Opacity" Value="1" />
  105. <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource RadioButton.Pressed.Glyph}" />
  106. </Trigger>
  107. <Trigger Property="IsChecked" Value="{x:Null}">
  108. <Setter TargetName="optionMark" Property="Opacity" Value="0.56" />
  109. </Trigger>
  110. </ControlTemplate.Triggers>
  111. </ControlTemplate>
  112. </Setter.Value>
  113. </Setter>
  114. </Style>
  115. <Style x:Key="SplitModeViewRadioBtn" TargetType="{x:Type RadioButton}">
  116. <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
  117. <Setter Property="Background" Value="{StaticResource RadioButton.Static.Background}" />
  118. <Setter Property="BorderBrush" Value="{StaticResource RadioButton.Static.Border}" />
  119. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
  120. <Setter Property="BorderThickness" Value="0" />
  121. <Setter Property="Width" Value="78" />
  122. <Setter Property="Height" Value="80" />
  123. <Setter Property="HorizontalContentAlignment" Value="Center" />
  124. <Setter Property="VerticalContentAlignment" Value="Center" />
  125. <Setter Property="Template">
  126. <Setter.Value>
  127. <ControlTemplate TargetType="{x:Type RadioButton}">
  128. <Grid
  129. x:Name="templateRoot"
  130. Background="Transparent"
  131. SnapsToDevicePixels="True">
  132. <Border
  133. x:Name="radioButtonBorder"
  134. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  135. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  136. Background="{TemplateBinding Background}"
  137. BorderBrush="{TemplateBinding BorderBrush}"
  138. BorderThickness="{TemplateBinding BorderThickness}">
  139. <Rectangle
  140. x:Name="optionMark"
  141. Width="{TemplateBinding Width}"
  142. Height="{TemplateBinding Height}"
  143. Opacity="0" />
  144. </Border>
  145. <ContentPresenter
  146. x:Name="contentPresenter"
  147. Margin="{TemplateBinding Padding}"
  148. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  149. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  150. Focusable="False"
  151. RecognizesAccessKey="True"
  152. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  153. </Grid>
  154. <ControlTemplate.Triggers>
  155. <Trigger Property="HasContent" Value="true">
  156. <Setter Property="FocusVisualStyle" Value="{StaticResource OptionMarkFocusVisual}" />
  157. <Setter Property="Padding" Value="4,-1,0,0" />
  158. </Trigger>
  159. <Trigger Property="IsMouseOver" Value="true">
  160. <Setter TargetName="radioButtonBorder" Property="Background" Value="{StaticResource RadioButton.MouseOver.Background}" />
  161. <Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{StaticResource RadioButton.MouseOver.Border}" />
  162. <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource RadioButton.MouseOver.Glyph}" />
  163. </Trigger>
  164. <Trigger Property="IsEnabled" Value="false">
  165. <Setter TargetName="radioButtonBorder" Property="Background" Value="{StaticResource RadioButton.Disabled.Background}" />
  166. <Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{StaticResource RadioButton.Disabled.Border}" />
  167. <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource RadioButton.Disabled.Glyph}" />
  168. </Trigger>
  169. <Trigger Property="IsPressed" Value="true">
  170. <Setter TargetName="radioButtonBorder" Property="Background" Value="{StaticResource RadioButton.Pressed.Background}" />
  171. <Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{StaticResource RadioButton.Pressed.Border}" />
  172. <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource RadioButton.Pressed.Glyph}" />
  173. </Trigger>
  174. <Trigger Property="IsChecked" Value="true">
  175. <Setter TargetName="optionMark" Property="Opacity" Value="1" />
  176. <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource RadioButton.Pressed.Glyph}" />
  177. </Trigger>
  178. <Trigger Property="IsChecked" Value="{x:Null}">
  179. <Setter TargetName="optionMark" Property="Opacity" Value="0.56" />
  180. </Trigger>
  181. </ControlTemplate.Triggers>
  182. </ControlTemplate>
  183. </Setter.Value>
  184. </Setter>
  185. </Style>
  186. <!-- 最近列表列表模式单选按钮 -->
  187. <Style x:Key="ListModeRadioBtnStyle" TargetType="{x:Type RadioButton}">
  188. <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
  189. <Setter Property="Background" Value="{StaticResource RadioButton.Static.Background}" />
  190. <Setter Property="BorderBrush" Value="{StaticResource RadioButton.Static.Border}" />
  191. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
  192. <Setter Property="Template">
  193. <Setter.Value>
  194. <ControlTemplate TargetType="{x:Type RadioButton}">
  195. <Border
  196. x:Name="root"
  197. Background="#EEF2F3"
  198. CornerRadius="4">
  199. <Grid
  200. x:Name="templateRoot"
  201. HorizontalAlignment="Center"
  202. VerticalAlignment="Center"
  203. SnapsToDevicePixels="True">
  204. <Grid.ColumnDefinitions>
  205. <ColumnDefinition Width="Auto" />
  206. <ColumnDefinition Width="*" />
  207. </Grid.ColumnDefinitions>
  208. <Border
  209. x:Name="radioButtonBorder"
  210. Margin="1,1,2,1"
  211. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  212. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  213. Background="{TemplateBinding Background}"
  214. BorderBrush="{TemplateBinding BorderBrush}"
  215. BorderThickness="{TemplateBinding BorderThickness}"
  216. CornerRadius="100"
  217. Visibility="Collapsed">
  218. <Grid x:Name="markGrid" Margin="2">
  219. <Ellipse
  220. x:Name="optionMark"
  221. MinWidth="6"
  222. MinHeight="6"
  223. Fill="{StaticResource RadioButton.Static.Glyph}"
  224. Opacity="0" />
  225. </Grid>
  226. </Border>
  227. <ContentPresenter
  228. x:Name="contentPresenter"
  229. Grid.Column="1"
  230. Margin="{TemplateBinding Padding}"
  231. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  232. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  233. Focusable="False"
  234. RecognizesAccessKey="True"
  235. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  236. </Grid>
  237. </Border>
  238. <ControlTemplate.Triggers>
  239. <Trigger Property="HasContent" Value="true">
  240. <Setter Property="FocusVisualStyle" Value="{StaticResource OptionMarkFocusVisual}" />
  241. <Setter Property="Padding" Value="4,-1,0,0" />
  242. </Trigger>
  243. <Trigger Property="IsMouseOver" Value="true">
  244. <Setter TargetName="radioButtonBorder" Property="Background" Value="{StaticResource RadioButton.MouseOver.Background}" />
  245. <Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{StaticResource RadioButton.MouseOver.Border}" />
  246. <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource RadioButton.MouseOver.Glyph}" />
  247. </Trigger>
  248. <Trigger Property="IsEnabled" Value="false">
  249. <Setter TargetName="radioButtonBorder" Property="Background" Value="{StaticResource RadioButton.Disabled.Background}" />
  250. <Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{StaticResource RadioButton.Disabled.Border}" />
  251. <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource RadioButton.Disabled.Glyph}" />
  252. <Setter TargetName="root" Property="Border.Background">
  253. <Setter.Value>
  254. <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
  255. <GradientStop Offset="0.0" Color="White" />
  256. <GradientStop Offset="0.5" Color="#CFCFCF" />
  257. <GradientStop Offset="0.0" Color="White" />
  258. </LinearGradientBrush>
  259. </Setter.Value>
  260. </Setter>
  261. </Trigger>
  262. <Trigger Property="IsPressed" Value="true">
  263. <Setter TargetName="radioButtonBorder" Property="Background" Value="{StaticResource RadioButton.Pressed.Background}" />
  264. <Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{StaticResource RadioButton.Pressed.Border}" />
  265. <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource RadioButton.Pressed.Glyph}" />
  266. </Trigger>
  267. <Trigger Property="IsChecked" Value="true">
  268. <Setter TargetName="optionMark" Property="Opacity" Value="1" />
  269. <Setter TargetName="root" Property="Border.Background" Value="White" />
  270. </Trigger>
  271. <Trigger Property="IsChecked" Value="{x:Null}">
  272. <Setter TargetName="optionMark" Property="Opacity" Value="0.56" />
  273. </Trigger>
  274. </ControlTemplate.Triggers>
  275. </ControlTemplate>
  276. </Setter.Value>
  277. </Setter>
  278. </Style>
  279. <!-- 悬浮灰色背景单选按钮 -->
  280. <Style x:Key="GreyBgRadioBtnStyle" TargetType="{x:Type RadioButton}">
  281. <Setter Property="BorderThickness" Value="1" />
  282. <Setter Property="Foreground" Value="#252629" />
  283. <Setter Property="Template">
  284. <Setter.Value>
  285. <ControlTemplate TargetType="{x:Type RadioButton}">
  286. <Border
  287. x:Name="templateRoot"
  288. Background="{TemplateBinding Background}"
  289. CornerRadius="4"
  290. SnapsToDevicePixels="True">
  291. <ContentPresenter
  292. x:Name="contentPresenter"
  293. Grid.Column="1"
  294. Margin="{TemplateBinding Padding}"
  295. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  296. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  297. Focusable="False"
  298. RecognizesAccessKey="True"
  299. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  300. </Border>
  301. <ControlTemplate.Triggers>
  302. <Trigger Property="HasContent" Value="true">
  303. <Setter Property="FocusVisualStyle" Value="{StaticResource OptionMarkFocusVisual}" />
  304. <Setter Property="Padding" Value="4,-1,0,0" />
  305. </Trigger>
  306. <Trigger Property="IsMouseOver" Value="true">
  307. <Setter TargetName="templateRoot" Property="Background" Value="#EDEEF0" />
  308. </Trigger>
  309. <Trigger Property="IsEnabled" Value="false">
  310. <Setter TargetName="templateRoot" Property="Opacity" Value="0.5" />
  311. </Trigger>
  312. <Trigger Property="IsPressed" Value="true" />
  313. <Trigger Property="IsChecked" Value="true">
  314. <Setter TargetName="templateRoot" Property="Background">
  315. <Setter.Value>
  316. <SolidColorBrush Opacity="0.6" Color="#CED0D4" />
  317. </Setter.Value>
  318. </Setter>
  319. <Setter TargetName="templateRoot" Property="BorderBrush" Value="#CED0D4" />
  320. <Setter Property="Foreground" Value="#616469" />
  321. <Setter TargetName="templateRoot" Property="BorderThickness" Value="1" />
  322. </Trigger>
  323. <Trigger Property="IsChecked" Value="{x:Null}" />
  324. </ControlTemplate.Triggers>
  325. </ControlTemplate>
  326. </Setter.Value>
  327. </Setter>
  328. </Style>
  329. </ResourceDictionary>