Is there a single event like Changed
that I can use to handle both events together?
Why are they separated like this?
Is it because having a single event for both would requires you to reference the control by name, which you would need to specify in the XAML, and this would increase the clutter?
IsChecked
property of the sender
parameter (after casting it to CheckBox
or ToggleButton
of course).EventTriggers
and similar. EventTriggers
can't distinguish between state, only by event, so two different events are needed.On a general note: I wouldn't use the events at all - I would bind the IsChecked
property to an appropiate property on your ViewModel
, keeping your code-behind to a minimum (Ideally no custom code at all).
The split gives more granularity for those who need it (can't hurt for those who don't) and if you want you can handle both events with one handler.
<CheckBox Content="CheckBox" Name="checkBox1" Checked="checkBox1_changed" Unchecked="checkBox1_changed" />
For example to start a storyboard when checked and stop it when unchecked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With