I'm using MahApps.Metro for my WPF app. As shown in the image below, the Forground
color of a CheckBox
remains default (black) if I try to change it to white.
Question: How can we change the content color to white?
None of the following XAMLs change the content's forground color. It remains default (black):
<CheckBox x:Name="chkTest" Content="Test Content" FontSize="20" Foreground="{StaticResource MahApps.Brushes.Badged.Foreground}" />
Or:
<CheckBox x:Name="chkTest" Content="Set Default" FontSize="20" Foreground="White" />
Or -as discussed here:
<CheckBox x:Name="chkTest" Content="Test Content" FontSize="20" Foreground="{StaticResource MahApps.Brushes.CheckBox.ForegroundChecked}" />
Display of the above XAMLs:
The MahApps.Metro CheckBox
style has many states and triggers, which use different brushes. Overriding the Forground
property does not cover all states.
However, there is a dedicated type CheckBoxHelper
with many attached properties that you can use to customize every brush in each state for the content, as well as for the check mark glyph. Look for properties starting with Foreground...
and CheckGlyphForeground...
. There are attached properties for check mark and content background as well.
<CheckBox x:Name="chkTest" Content="Set Default" FontSize="20"
mah:CheckBoxHelper.ForegroundUnchecked="Blue"
mah:CheckBoxHelper.ForegroundUncheckedMouseOver="Green"
mah:CheckBoxHelper.CheckGlyphForegroundChecked="Red"
mah:CheckBoxHelper.CheckGlyphForegroundCheckedMouseOver="Purple"/>