I've just started a new project in which the presentation layer will be done by WPF and MVVM Light by GalaSoft.
I need a lot of views and it's not clear to me how to manage navigation through windows.
First of all, the templates offered in MVVM Light for creating a new "WPF MVVM View" create a new Window
that is not possible to use for navigation by frame (I mean, by putting a frame in mainView
and changing the source path to navigate).
Do I simply have to change Window
to Page
for all the views I create using templates?
Or is there a different way to perform navigation in WPF with the MVVM Light toolkit?
I usually use a ContentControl
to display dynamic content. It's Content
property is usually bound to a CurrentViewModel
property in the parent ViewModel
, and DataTemplates
are used to tell WPF how to draw the child ViewModels
.
To change views, simply change the CurrentViewModel
property in the parent ViewModel
You can find an example at this article of mine