When developing a wpf app for work I ran into a display problem for the CheckBox and RadioButton. Most of our office computers still use windows XP with the classic theme and even the new Windows 7 computers are set to use the classic theme as well.
Originally, I wrote my RadioButton and CheckBox like so
Name=”radioButton1″ GroupName=”someGroup” Content=”Option 1″ />
<RadioButton Style="{StaticResource myRadio}"
As you can see the “Content” part is what determined my label for the defined RadioButton, and here is where the problem is. I am not sure why but the Classic theme in windows can’t render this properly causing the entire control to be inaccessible.
To fix this problem we need to remove “content” and link a label to the control. This is quite simple to do as you can see as follows:
<RadioButton Style="{StaticResource myRadio}" GroupName="someGroup" Name="radioButton1">
<Label>Option 1</Label>
</RadioButton>
I would like to know more why this is a problem on the classic theme but right now this workaround works great across all OS’s and themes
Permalink
Thanks for the help with this head scratcher!
Permalink
It sure was a big headache!
Permalink
Thanks for the workaround.
I know it is years later, but I thought I would add some explanation.
We ran into the problem when using a dark background. We set the control foreground color to White, since it determined the color of the text content displayed alongside the selection item.
This worked fine as long as desktop composition was enabled in Windows 7. If the Windows Classic theme was chosen, disabling desktop composition, you wouldn’t be able to see the white check or radio selection over the default white background.
Nesting a label control as content under the check box or radio button lets you set the foreground color only on the child control.