In my app I have toggle buttons that have three possible states; "Unchecked", "Checked", and "Previously Used". When the user comes to this particular screen, some of the toggle buttons will be in the "Previously Used" state to show what work has been done. Clicking on a toggle button (no matter the current state) will place it into the "Checked" state. Only one of these toggle buttons can be checked at a time. The different states are indicated by different colored outer glow, or no glow at all.
To set the outer glow for the "Checked" state I use a trigger on IsChecked euqals true.
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect Color="Salmon" BlurRadius="40" ShadowDepth="0" Opacity="1.0"></DropShadowEffect>
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
For the "Previously Used" state I apply the outer glow in code, not markup. I have to do this because determining if the button should be in this state is done by checking values in a List.
if (mExistingViews.Contains(mViews[i].LocalizedName))
{
DropShadowEffect dse = new DropShadowEffect();
dse.ShadowDepth = 0;
dse.BlurRadius = 20;
dse.Opacity = 1.0;
dse.Color = Colors.Yellow;
mViewButtons[i].Effect = dse;
}
However, when a toggle button is clicked when in the "Previously Used" state, the trigger doesn't seem to have any effect. The outer glow does not change.
What am I doing wrong? Will a trigger not effect something that has not been set in XAML?