I am using MVVM architecture.
I have a usercontrol UC as a View
Model is a ModelData class
ViewModel (UCViewModel) is binded to a usercontrol.
I have three more usercontrols that is inside the usercontrol UC ( discussed above).
Let's say uc1, uc2 and uc3.
and the visibility of uc1 , uc2 and uc3 inside UC depends on the type selected ( which ever radio button is selected ).
Since UC is binded to UCViewModel and I have to do all the stuff related to uc1 , uc2 and uc3 inside UCViewModel. Can I have seperate VM to uc1 , uc2 and uc3.. if Yes how can i do that ? Please Help!!
As far as I understand your question, you can solve this by having
UC
expose aSelectedSubView
(or whatever) property:At the same time, you bind the radiobuttons to other properties of
UC
and updateSelectedSubView
accordingly (remember to implement INotifyPropertyChanged). Based on the selected radiobutton properties, theSelectedSubView
must return the appropriate ViewModel.You then bind a ContentPresenter to the
SelectedSubView
property and use DataTemplates to select the correct user controls (uc1, uc2 or uc3) based on the type of the currentSelectedSubView
.Since you only want to hide inactive Views, it's probably best to keep their respective ViewModels around, so you may want to make them fields in the
UC
class