ZCheckBox.xaml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <ResourceDictionary
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:ZUI="clr-namespace:CustomUI">
  5. <Style TargetType="{x:Type ZUI:ZCheckBox}">
  6. <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  7. <Setter Property="Background" Value="White" />
  8. <Setter Property="BorderBrush" Value="#CED9E8" />
  9. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
  10. <Setter Property="BorderThickness" Value="1" />
  11. <Setter Property="SnapsToDevicePixels" Value="True" />
  12. <Setter Property="CornerRadius" Value="2" />
  13. <Setter Property="UseLayoutRounding" Value="True" />
  14. <Setter Property="VerticalContentAlignment" Value="Center" />
  15. <Setter Property="Template">
  16. <Setter.Value>
  17. <ControlTemplate TargetType="{x:Type ZUI:ZCheckBox}">
  18. <Grid
  19. x:Name="templateRoot"
  20. Background="Transparent"
  21. SnapsToDevicePixels="True">
  22. <Grid.ColumnDefinitions>
  23. <ColumnDefinition Width="Auto" />
  24. <ColumnDefinition Width="*" />
  25. </Grid.ColumnDefinitions>
  26. <Border
  27. x:Name="checkBoxBorder"
  28. Width="16"
  29. Height="15"
  30. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  31. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  32. Background="{TemplateBinding Background}"
  33. BorderBrush="{TemplateBinding BorderBrush}"
  34. BorderThickness="{TemplateBinding BorderThickness}"
  35. CornerRadius="{TemplateBinding CornerRadius}"
  36. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  37. UseLayoutRounding="{TemplateBinding UseLayoutRounding}">
  38. <Grid
  39. x:Name="markGrid"
  40. HorizontalAlignment="Center"
  41. VerticalAlignment="Center">
  42. <Path
  43. x:Name="optionMark"
  44. Width="10"
  45. Margin="0"
  46. Data="F1M9.97498,1.22334L4.6983,9.09834 4.52164,9.09834 0,5.19331 1.27664,3.52165 4.255,6.08833 8.33331,1.52588E-05 9.97498,1.22334z"
  47. Fill="#00FFFFFF"
  48. Stretch="Uniform" />
  49. <Rectangle
  50. x:Name="indeterminateMark"
  51. Margin="2"
  52. Fill="#FF212121"
  53. Opacity="0" />
  54. </Grid>
  55. </Border>
  56. <ContentPresenter
  57. x:Name="contentPresenter"
  58. Grid.Column="1"
  59. Margin="{TemplateBinding Padding}"
  60. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  61. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  62. Content="{TemplateBinding Content}"
  63. ContentStringFormat="{TemplateBinding ContentStringFormat}"
  64. ContentTemplate="{TemplateBinding ContentTemplate}"
  65. Focusable="False"
  66. RecognizesAccessKey="True"
  67. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  68. </Grid>
  69. <ControlTemplate.Triggers>
  70. <Trigger Property="HasContent" Value="True">
  71. <Setter Property="Padding" Value="4,0,0,0" />
  72. </Trigger>
  73. <Trigger Property="IsMouseOver" Value="True">
  74. <Setter TargetName="checkBoxBorder" Property="BorderBrush" Value="#6452A4" />
  75. <Setter TargetName="indeterminateMark" Property="Fill" Value="#FF212121" />
  76. </Trigger>
  77. <Trigger Property="IsEnabled" Value="False">
  78. <Setter TargetName="checkBoxBorder" Property="Background" Value="#FFE6E6E6" />
  79. <Setter TargetName="checkBoxBorder" Property="BorderBrush" Value="#FFBCBCBC" />
  80. <Setter TargetName="optionMark" Property="Fill" Value="#FF707070" />
  81. <Setter TargetName="indeterminateMark" Property="Fill" Value="#FF707070" />
  82. </Trigger>
  83. <Trigger Property="IsPressed" Value="True">
  84. <Setter TargetName="checkBoxBorder" Property="BorderBrush" Value="#6452A4" />
  85. <Setter TargetName="indeterminateMark" Property="Fill" Value="#FF212121" />
  86. </Trigger>
  87. <Trigger Property="IsChecked" Value="True">
  88. <Setter TargetName="checkBoxBorder" Property="BorderBrush" Value="#6452A4" />
  89. <Setter TargetName="checkBoxBorder" Property="Background" Value="#6452A4" />
  90. <Setter TargetName="optionMark" Property="Fill" Value="#FFFFFF" />
  91. <Setter TargetName="indeterminateMark" Property="Opacity" Value="0" />
  92. </Trigger>
  93. <Trigger Property="IsChecked" Value="{x:Null}">
  94. <Setter TargetName="optionMark" Property="Opacity" Value="0" />
  95. <Setter TargetName="indeterminateMark" Property="Opacity" Value="1" />
  96. </Trigger>
  97. </ControlTemplate.Triggers>
  98. </ControlTemplate>
  99. </Setter.Value>
  100. </Setter>
  101. </Style>
  102. </ResourceDictionary>