tags:

views:

62

answers:

1

Can somone give me an example why would I need a ViewModel taht contains two sub View models ? and how do I implement this ?

+1  A: 

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.

cwap