Reputation: 85
Im trying to learn MVVM so far its going well , I have stumble on a situation which I don't know how to implement ..
What I want : - A view with left navigation and right details pane .. right details will have a contentcontainer which would hold my User Controls for the views to be selected by left pane
What I have : - A MainViewModel - ViewModels for Each of the Entities I have on my database
My Problem : - Since I will have an ObservableCollection of my VIEWMODELS in my MAINVIEWMODEL ( as per the example i'm patterning my application ) do I create a public property for each of my MODEL Entities which will be used for the databinding I have defined in my UserControls ??
Upvotes: 3
Views: 1884
Reputation: 1827
Have a look at John Papa's PDC talk 'Advanced Topics for Building Large-Scale Applications with Microsoft Silverlight'. In it he illustrates an approach for managing an application that has multiple MVVM triads.
Upvotes: 2
Reputation: 50038
You can create a Base Type for all of your ViewModels to be displayed on the right side.(lets call that as BaseContentViewModel)
Then your left side ListBox will be bind to ObservableCollection<BaseContentViewModel>
and the SelectedValue of the ListBox will bind to a new MainViewModel.SelectedContent proeprty of Type BaseContentViewModel.
And on the right side you need to have a ContentControl to which SelectedContent bind to ContentControl.Content
Now it is just a matter of defining different UserControls as DataTemplates in the Resource XAMLs (Usually refers as ViewToViewModelMapping in MVVM)
Upvotes: 5