Reputation: 869
I'm using MVVM in WPF.
In CheckBox control i can bind command to DelegateCommand to trace changes and I can also bind IsChecked property to my ViewModel.
What is better and what is difference between the 2 options?
Upvotes: 2
Views: 235
Reputation: 30428
It depends on what you want to do when the checked state of the check box changes.
If all you care about is if the check box is checked or not, then binding to IsChecked
is the right way to go.
If you want to do something in response to the checked state changing, then binding to the command will allow you to easily do something in this case.
Upvotes: 1
Reputation: 44068
Using IsChecked
makes more sense to me.
This way you have a bool property in the ViewModel and can react to changes and place your logic in the setter
, and avoid the extra boilerplate of the DelegateCommand
.
Upvotes: 1