Skip to content

Commit bda4f23

Browse files
committed
Background support for MaterialDesignCheckBox
Added background template support for material design checkbox (before it was fixed to primary mid hue), plus also 3 new styles: MaterialDesignLightCheckBox, MaterialDesignDarkCheckBox, MaterialDesignActionCheckBox Also consider removing MaterialDesignUserForegroundCheckbox, since it does not allow you to select a different color for the checkbox and the text.
1 parent b9ec6f7 commit bda4f23

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.CheckBox.xaml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
<Style x:Key="MaterialDesignCheckBox" TargetType="{x:Type CheckBox}">
4848
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
4949
<Setter Property="BorderThickness" Value="1"/>
50+
<Setter Property="Background" Value="{DynamicResource PrimaryHueMidBrush}"/>
51+
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueMidBrush}"/>
5052
<Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}"/>
5153
<Setter Property="Template">
5254
<Setter.Value>
@@ -114,7 +116,7 @@
114116
<Trigger Property="IsPressed" Value="true"/>
115117
<Trigger Property="IsChecked" Value="true">
116118
<Setter Property="Data" TargetName="Graphic" Value="M10,17L5,12L6.41,10.58L10,14.17L17.59,6.58L19,8M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3Z" />
117-
<Setter Property="Fill" TargetName="Graphic" Value="{DynamicResource PrimaryHueMidBrush}" />
119+
<Setter Property="Fill" TargetName="Graphic" Value="{TemplateBinding Background}" />
118120
</Trigger>
119121
<Trigger Property="IsChecked" Value="{x:Null}">
120122
<Setter Property="Data" TargetName="Graphic" Value="M10,17L5,12L6.41,10.58L10,14.17L17.59,6.58L19,8M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3Z" />
@@ -126,6 +128,24 @@
126128
</Setter>
127129
</Style>
128130

131+
<Style x:Key="MaterialDesignLightCheckBox" TargetType="{x:Type CheckBox}" BasedOn="{StaticResource MaterialDesignCheckBox}">
132+
<Setter Property="Background" Value="{DynamicResource PrimaryHueLightBrush}"/>
133+
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueLightBrush}"/>
134+
<Setter Property="Foreground" Value="{DynamicResource PrimaryHueLightForegroundBrush}"/>
135+
</Style>
136+
137+
<Style x:Key="MaterialDesignDarkCheckBox" TargetType="{x:Type CheckBox}" BasedOn="{StaticResource MaterialDesignCheckBox}">
138+
<Setter Property="Background" Value="{DynamicResource PrimaryHueDarkBrush}"/>
139+
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryHueDarkBrush}"/>
140+
<Setter Property="Foreground" Value="{DynamicResource PrimaryHueDarkForegroundBrush}"/>
141+
</Style>
142+
143+
<Style x:Key="MaterialDesignAccentCheckBox" TargetType="{x:Type CheckBox}" BasedOn="{StaticResource MaterialDesignCheckBox}">
144+
<Setter Property="Background" Value="{DynamicResource SecondaryAccentBrush}"/>
145+
<Setter Property="BorderBrush" Value="{DynamicResource SecondaryAccentBrush}"/>
146+
<Setter Property="Foreground" Value="{DynamicResource SecondaryAccentForegroundBrush}"/>
147+
</Style>
148+
129149
<Style x:Key="MaterialDesignUserForegroundCheckBox" TargetType="{x:Type CheckBox}">
130150
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
131151
<Setter Property="BorderThickness" Value="1"/>
@@ -206,4 +226,4 @@
206226
</Setter>
207227
</Style>
208228

209-
</ResourceDictionary>
229+
</ResourceDictionary>

0 commit comments

Comments
 (0)