When I turn on IsCheckable to true multiple checkboxes can be checked. But I want to check only one checkbox at a time within the context Menu. I referred this link -> Mutually exclusive checkable menu items? most of the solutions are non MVVM. I am looking for MVVM , wpf solution
-
4I don't see why the answer in the link isn't "MVVM". – dowhilefor Aug 14 '13 at 14:03
-
I found the MVVM solution too complex for the simple scenario. Thanks for your response I was able to get this done in simple way by passing header as commandparameter – user2596010 Aug 15 '13 at 13:57
1 Answers
The link that you provided is a solution.
Abuse the dependency/attach properties stop pursuing that everything in WPF can be done in MVVM in a clean way. This is the typical mindset of most of the developers when they are coding in WPF.
Note: If you're gonna encounter this problem in another view and you've implemented it using MVVM, then you'll end up having duplicate codes for your ViewModels.
You use dependency/attach properties if you want to reuse the logic for a different view that has exact problem too!
And another side note: Does these checkbox require any of the "Business logic" ViewModel so that there would only be one checkbox checked? If not, then no you're doing it wrong.
"I have to follow the MVVM Pattern, or else I'm not doing it right"

- 10,565
- 4
- 43
- 72
-
Sorry for the late reply. I agree with you. There are times where in we cannot stick to MVVM solution. But for the current problem that I am facing I needed an MVVM solution. I was able to get this done in MVVM by passing header as commandparameter and in viewmodel handling IsChecked value. – user2596010 Aug 15 '13 at 13:55