CheckBoxStyle.xaml 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. <SolidColorBrush x:Key="OptionMark.Static.Background" Color="#FFFFFFFF" />
  17. <SolidColorBrush x:Key="OptionMark.Static.Border" Color="#FF707070" />
  18. <SolidColorBrush x:Key="OptionMark.MouseOver.Background" Color="White" />
  19. <SolidColorBrush x:Key="OptionMark.MouseOver.Border" Color="Black" />
  20. <SolidColorBrush x:Key="OptionMark.MouseOver.Glyph" Color="White" />
  21. <SolidColorBrush x:Key="OptionMark.Disabled.Background" Color="#FFE6E6E6" />
  22. <SolidColorBrush x:Key="OptionMark.Disabled.Border" Color="#FFBCBCBC" />
  23. <SolidColorBrush x:Key="OptionMark.Disabled.Glyph" Color="#FF707070" />
  24. <SolidColorBrush x:Key="OptionMark.Pressed.Background" Color="#FFD9ECFF" />
  25. <SolidColorBrush x:Key="OptionMark.Pressed.Border" Color="#FF3C77DD" />
  26. <SolidColorBrush x:Key="OptionMark.Pressed.Glyph" Color="White" />
  27. <SolidColorBrush x:Key="OptionMark.Static.Glyph" Color="White" />
  28. <ControlTemplate x:Key="MenuCheckbox" TargetType="{x:Type CheckBox}">
  29. <Grid
  30. x:Name="templateRoot"
  31. Background="Transparent"
  32. SnapsToDevicePixels="True">
  33. <Grid.ColumnDefinitions>
  34. <ColumnDefinition Width="Auto" />
  35. <ColumnDefinition Width="*" />
  36. </Grid.ColumnDefinitions>
  37. <Border
  38. x:Name="checkBoxBorder"
  39. Width="20"
  40. Height="20"
  41. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  42. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  43. BorderBrush="{TemplateBinding BorderBrush}"
  44. BorderThickness="1">
  45. <Grid x:Name="markGrid">
  46. <Polygon
  47. x:Name="optionMark"
  48. Width="20"
  49. Height="20"
  50. Margin="1,0,0,0"
  51. VerticalAlignment="Center"
  52. Fill="{StaticResource OptionMark.Static.Glyph}"
  53. Opacity="0"
  54. Points="15.5992424 4.59619408 16.3063492 5.30330086 5.69974747 15.9099026 0.396446609 10.6066017 1.10355339 9.89949494 5.7 14.496" />
  55. <Rectangle
  56. x:Name="indeterminateMark"
  57. Width="20"
  58. Height="20"
  59. Fill="{StaticResource OptionMark.Static.Glyph}"
  60. Opacity="0" />
  61. </Grid>
  62. </Border>
  63. <ContentPresenter
  64. x:Name="contentPresenter"
  65. Grid.Column="1"
  66. Margin="{TemplateBinding Padding}"
  67. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  68. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  69. Focusable="False"
  70. RecognizesAccessKey="True"
  71. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  72. </Grid>
  73. <ControlTemplate.Triggers>
  74. <Trigger Property="HasContent" Value="true">
  75. <Setter Property="FocusVisualStyle" Value="{StaticResource OptionMarkFocusVisual}" />
  76. <Setter Property="Padding" Value="4,-1,0,0" />
  77. </Trigger>
  78. <Trigger Property="IsMouseOver" Value="true">
  79. <Setter TargetName="checkBoxBorder" Property="Background" Value="{StaticResource OptionMark.MouseOver.Background}" />
  80. <Setter TargetName="checkBoxBorder" Property="BorderBrush" Value="{StaticResource OptionMark.MouseOver.Border}" />
  81. <Setter TargetName="checkBoxBorder" Property="BorderThickness" Value="2" />
  82. <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource OptionMark.MouseOver.Glyph}" />
  83. <Setter TargetName="indeterminateMark" Property="Fill" Value="{StaticResource OptionMark.MouseOver.Glyph}" />
  84. </Trigger>
  85. <Trigger Property="IsEnabled" Value="false">
  86. <Setter TargetName="checkBoxBorder" Property="Background" Value="{StaticResource OptionMark.Disabled.Background}" />
  87. <Setter TargetName="checkBoxBorder" Property="BorderBrush" Value="{StaticResource OptionMark.Disabled.Border}" />
  88. <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource OptionMark.Disabled.Glyph}" />
  89. <Setter TargetName="indeterminateMark" Property="Fill" Value="{StaticResource OptionMark.Disabled.Glyph}" />
  90. </Trigger>
  91. <Trigger Property="IsPressed" Value="true">
  92. <Setter TargetName="checkBoxBorder" Property="Background" Value="{StaticResource OptionMark.Pressed.Background}" />
  93. <Setter TargetName="checkBoxBorder" Property="BorderBrush" Value="{StaticResource OptionMark.Pressed.Border}" />
  94. <Setter TargetName="optionMark" Property="Fill" Value="{StaticResource OptionMark.Pressed.Glyph}" />
  95. <Setter TargetName="indeterminateMark" Property="Fill" Value="{StaticResource OptionMark.Pressed.Glyph}" />
  96. </Trigger>
  97. <Trigger Property="IsChecked" Value="true">
  98. <Setter TargetName="optionMark" Property="Opacity" Value="1" />
  99. <Setter TargetName="indeterminateMark" Property="Opacity" Value="0" />
  100. <Setter TargetName="checkBoxBorder" Property="Background" Value="#FF0078D7" />
  101. </Trigger>
  102. <Trigger Property="IsChecked" Value="{x:Null}">
  103. <Setter TargetName="optionMark" Property="Opacity" Value="0" />
  104. <Setter TargetName="indeterminateMark" Property="Opacity" Value="1" />
  105. </Trigger>
  106. </ControlTemplate.Triggers>
  107. </ControlTemplate>
  108. <Style x:Key="EditToolsCheckBoxStyle" TargetType="{x:Type CheckBox}">
  109. <Setter Property="SnapsToDevicePixels" Value="true" />
  110. <Setter Property="OverridesDefaultStyle" Value="False" />
  111. <Setter Property="Height" Value="22" />
  112. <Setter Property="IsChecked" Value="False" />
  113. <Setter Property="Template">
  114. <Setter.Value>
  115. <ControlTemplate TargetType="CheckBox">
  116. <Grid>
  117. <Grid.ColumnDefinitions>
  118. <ColumnDefinition Width="Auto" />
  119. <ColumnDefinition Width="*" />
  120. </Grid.ColumnDefinitions>
  121. <Grid Width="{TemplateBinding Height}" Height="{TemplateBinding Height}">
  122. <Rectangle
  123. x:Name="CheckBoxRectangle"
  124. Fill="White"
  125. Opacity="0.3"
  126. RadiusX="2"
  127. RadiusY="2" />
  128. <Rectangle
  129. x:Name="CheckBoxRectangleOut"
  130. RadiusX="1"
  131. RadiusY="2"
  132. Stroke="Black"
  133. StrokeThickness="1" />
  134. <Grid
  135. x:Name="CheckedMark"
  136. Width="20"
  137. Height="20"
  138. Visibility="Collapsed">
  139. <Path
  140. Data="M1,9 L10,17"
  141. SnapsToDevicePixels="False"
  142. Stroke="White"
  143. StrokeThickness="3" />
  144. <Path
  145. Data="M8,17 L20,4"
  146. SnapsToDevicePixels="False"
  147. Stroke="White"
  148. StrokeThickness="3" />
  149. </Grid>
  150. </Grid>
  151. <TextBlock
  152. Grid.Column="1"
  153. Margin="14,0,0,0"
  154. VerticalAlignment="Center"
  155. FontSize="18"
  156. Foreground="Black"
  157. Text="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" />
  158. </Grid>
  159. <ControlTemplate.Triggers>
  160. <Trigger Property="IsChecked" Value="True">
  161. <Setter TargetName="CheckedMark" Property="Visibility" Value="Visible" />
  162. <Setter TargetName="CheckBoxRectangle" Property="Fill" Value="#FF00A8E0" />
  163. <Setter TargetName="CheckBoxRectangle" Property="Opacity" Value="1" />
  164. <Setter TargetName="CheckBoxRectangleOut" Property="Stroke" Value="Transparent" />
  165. <Setter TargetName="CheckedMark" Property="Visibility" Value="Visible" />
  166. <Setter TargetName="CheckBoxRectangle" Property="Fill" Value="#000000" />
  167. <Setter TargetName="CheckBoxRectangle" Property="Opacity" Value="1" />
  168. <Setter TargetName="CheckBoxRectangleOut" Property="Stroke" Value="Transparent" />
  169. </Trigger>
  170. </ControlTemplate.Triggers>
  171. </ControlTemplate>
  172. </Setter.Value>
  173. </Setter>
  174. </Style>
  175. </ResourceDictionary>