RadioButtonStyle.xaml 4.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  2. <Style x:Key="CheckRadioFocusVisual">
  3. <Setter Property="Control.Template">
  4. <Setter.Value>
  5. <ControlTemplate>
  6. <Rectangle Margin="-2"
  7. HorizontalAlignment="Stretch"
  8. VerticalAlignment="Stretch"
  9. SnapsToDevicePixels="true"
  10. Stroke="{DynamicResource FocusVisualBrush}"
  11. StrokeDashArray="1,2"
  12. StrokeThickness="1" />
  13. </ControlTemplate>
  14. </Setter.Value>
  15. </Setter>
  16. </Style>
  17. <Style x:Key="RadioButtonStyle" TargetType="{x:Type RadioButton}">
  18. <Setter Property="BorderBrush" Value="{DynamicResource CommonBorderBrush}" />
  19. <Setter Property="Foreground" Value="{DynamicResource MainForegroundBrush}" />
  20. <Setter Property="VerticalAlignment" Value="Center" />
  21. <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  22. <Setter Property="VerticalContentAlignment" Value="Center" />
  23. <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" />
  24. <Setter Property="Padding" Value="2,0,0,0" />
  25. <Setter Property="Template">
  26. <Setter.Value>
  27. <ControlTemplate TargetType="{x:Type RadioButton}">
  28. <Grid>
  29. <Rectangle Name="OutSideBorder"
  30. HorizontalAlignment="Stretch"
  31. VerticalAlignment="Stretch"
  32. SnapsToDevicePixels="true"
  33. Stroke="{DynamicResource FocusVisualBrush}"
  34. StrokeDashArray="1,2"
  35. StrokeThickness="1"
  36. Visibility="Collapsed" />
  37. <Grid Margin="1" SnapsToDevicePixels="False">
  38. <Grid.ColumnDefinitions>
  39. <ColumnDefinition Width="Auto" />
  40. <ColumnDefinition />
  41. </Grid.ColumnDefinitions>
  42. <Ellipse x:Name="Border"
  43. Width="17"
  44. Height="17"
  45. Fill="{DynamicResource ContentBackground}"
  46. Stroke="{TemplateBinding BorderBrush}"
  47. StrokeThickness="1" />
  48. <Ellipse x:Name="Dot"
  49. Grid.Column="0"
  50. Width="10"
  51. Height="10"
  52. Fill="{DynamicResource CheckedBrush}"
  53. Visibility="Collapsed" />
  54. <ContentPresenter Grid.Column="1"
  55. Margin="{TemplateBinding Padding}"
  56. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  57. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  58. RecognizesAccessKey="True" />
  59. </Grid>
  60. </Grid>
  61. <ControlTemplate.Triggers>
  62. <Trigger Property="IsChecked" Value="true">
  63. <Setter TargetName="Dot" Property="Visibility" Value="Visible" />
  64. </Trigger>
  65. <Trigger Property="IsPressed" Value="true">
  66. <Setter TargetName="Border" Property="Fill" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
  67. </Trigger>
  68. <Trigger Property="IsEnabled" Value="false">
  69. <Setter TargetName="Border" Property="Fill" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
  70. <Setter TargetName="Dot" Property="Fill" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
  71. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
  72. </Trigger>
  73. <Trigger Property="IsFocused" Value="true">
  74. <Setter TargetName="OutSideBorder" Property="Visibility" Value="Visible" />
  75. </Trigger>
  76. </ControlTemplate.Triggers>
  77. </ControlTemplate>
  78. </Setter.Value>
  79. </Setter>
  80. </Style>
  81. </ResourceDictionary>