Reputation: 6446
Can somone give me an example why would I need a ViewModel taht contains two sub View models ? and how do I implement this ?
Upvotes: 5
Views: 1450
Reputation: 11287
Assuming you got a "MainContainer" which is your top-level ViewModel, you might need 2 different sub-viewmodels: One for a "Menu" and one for the content that the menu points to.
It could be implemented like this:
public MenuViewModel Menu;
public ContentViewModel Content;
You'd bind a container in your main view to each of these viewmodels, and on update insert a view depending on your viewmodel. How you map the viewmodels to the view, can depend, and there's no "pretty" solution. Personally, I like to keep it in my top-view resources, using a datatemplate.
Upvotes: 3
Reputation: 273244
You could take a look at the End-to-end sample on this MSDN page. Unfortunately there is no walk-through but I found it instructional, a small but complete app using WPF, MVVM, EF4 and POCOs.
Upvotes: 1