Correcting the WPF Themes

I’m a big fan of themes in WPF — and I think it’s great that Microsoft has released a whole set of themes for Silverlight and WPF at www.codeplex.com/wpf


However, in using some of those themes, I’ve run into an annoying bug in the RadioButton template – specifically, the checked state doesn’t always show up initially.  Looking at the template, it turns out to be an easy fix.  The “CheckIcon” is set to an opacity of zero initially (so it’s not shown) and then a trigger is used to apply an animation to change the value.  Unfortunately, it looks like the animation is switched – it applies when the checkbox is UNCHECKED vs. CHECKED.  So, two ways to fix it — either change the initial opacity to “1” for the “CheckIcon” element in the control template, or go to the triggers in the control template for the RadioButton and swap the states so it looks like this:

<Trigger Property=”IsChecked” Value=”false” />
<Trigger Property=”IsChecked” Value=”True”>
<Trigger.EnterActions>
<BeginStoryboard x:Name=”CheckedOn_BeginStoryboard” Storyboard=”{StaticResource CheckedOn}”/>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard x:Name=”CheckedOff_BeginStoryboard” Storyboard=”{StaticResource CheckedOff}”/>
</Trigger.ExitActions>
</Trigger>

About Mark Smith

Windows systems developer with low-level operating system, threading and .NET experience. For the past several years I have been involved with WPF/Silverlight and most recently iOS and Android.

I have worked as an architect and designer for several companies and am particularly interested in client/server and graphical solutions.

Specialties:.NET, WPF, Silverlight, Windows, iOS