I have a WPF application and three-state CheckBox on it. I created a custom template for the check-box and want animate it like a slider (move slider left and right). I've created a slider and set the triggers:
<ControlTemplate TargetType="{x:Type CheckBox}">
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource SwitchOn}" />
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource SwitchOff}" />
</Trigger.ExitActions>
</Trigger>
<Trigger Property="IsChecked" Value="False">
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource SwitchOff}" />
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource SwitchOn}" />
</Trigger.ExitActions>
</Trigger>
<Trigger Property="IsChecked" Value="{x:Null}">
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource SwitchMiddle}" />
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource SwitchOff}" />
</Trigger.ExitActions>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
This style applied to the two-state checkbox is works perfectly on checkbox toggle in such cycle: switch on -> switch off ... and so on.
But when I apply it to three-state checkbox, the animation cycle is works good (what I need) only once: switch on -> switch middle -> switch off
And after that the cycle is repeats like this: switch off -> switch middle -> switch off -> switch off -> switch middle ...
I tried many different combinations of the enter actions and exit actions, but unsuccessfully. What is the right way to create a triggers to excpected behavior? Thanks!
Aucun commentaire:
Enregistrer un commentaire