I\'ve created a simple WPF application which has two Windows. The user fills in some information on the first Window and then clicks Ok which will take them to the second Window
I use ContentPresenter for snapping in content. In the window, I put something like this:
In the view model, I have a property called MainContent of type object:
public object MainContent { get { return (object)GetValue(MainContentProperty); } set { SetValue(MainContentProperty, value); } }
public static readonly DependencyProperty MainContentProperty = DependencyProperty.Register("MainContent", typeof(object), typeof(SomeViewModel), new FrameworkPropertyMetadata(null));
Whatever you set MainContent to will show up in the window.
To keep the separation between view and view model, I typically set the MainContent property to another view model and use a data template to map that view model to a view:
I put that data template in some central resource dictionary along with a bunch of other view-model-to-view mappers.