I am working on wpf mvvm pattern. I have different user controls. Based on the checkbox selection, I want them to be loaded in the main screen (that is also a user control). I have one HomeViewModel class which I have been using to bind the user controls of my project. Can you help me with a suitable way?
1 Answer
You should have different ViewModels for each kinds of UserControl.
- Create different DataTemplates for each ViewModel Types
- Put a ContentControl with binding a property of HomeViewModel -
- Value of property will be an instance of ViewModel ( UserControl's) and is set by toggling CheckBoxes.