tags:

views:

61

answers:

3

In my simple WPF application I use regular CheckBox control. It looks like I can control background and foreground. Foreground property controls the text next to the check box but not the check mark. By default background is white, my foreground is very close to white because I have a dark windows form background.

When I run the application on my development Windows 7 machine the check mark is black. On Win XP computer the check mark is green. However on another Win XP machine the check mark is invisible because it's white on white.

My question is "How can I control the color of a check mark of my check box?".

+1  A: 

You need to override the ControlTemplate of the CheckBox.

Here's an example on MSDN.

Wonko the Sane
@Wonko, thanks. It's not as simple as I hoped but I'm looking into it.
Vadim
If you have Blend, you can always use the Edit Template command (sorry, I don't have Blend here, so I can't tell you the exact command) to get the default template. Or, you can use something like Snoop.
Wonko the Sane
A: 

Alternatively, I think you could define a style that defines a trigger that changes the color as you desire. Since it's interesting I'll try it out and post a sample in a bit.

Edit: nevermind, the CheckBox uses BulletChrome which does some rendering internally and doesn't expose any interesting properties that could be used to hook into.

Alex Paven
@Alex, Thanks a lot for looking into it.
Vadim
A: 

This issue happens on Win XP that uses'Windows Classic' theme or using Remote Desktop. Bullet check mark of a check box takes color of foreground color for the whole CheckBox.

<CheckBox Foreground="White" Content="My Text" />

I was able to fix this problem by changing to the code below:

<CheckBox>
   <Label Foreground="White">My Text</Label>
</CheckBox>
Vadim