Hi I am building a wpf application in which a screen will be comprising of different user controls for performing various application.
I wanted to know the right process for doing this in MVVM? Should each user control have its own view model, or should they still bind to the main View model properties?
Please suggest a good approach. Thanks,
When I use an UserControl I pass the data through DependencyProperties. My UserControls doesn’t have ViewModels. UserControls only handle the passed data a very special way.
But if I have View that contains some Sub-Views I prefere to have for each Sub-View a own model. These model I’ll bind through a property of the ViewModel of the MainView.
Some example:
UserControl1, Code behind:
And the usage in the view, XAML:
Hope this helps