C# – MVVM Light Toolkit NavigationService implementation for WPF using a Frame

cmvvmmvvm-lightwpf

I am starting to learn MVVM and am trying to use the MVVM Light Toolkit in a WPF project. In the app I will need to navigate to numerous pages and navigate back also. I know I need a NavigationService that I should register with the SimpleIoc.

However, it appears the toolkit doesn't have an implementation of a NavigationService for use in WPF, only offering an INavigationService interface. In my MainWindow I have a Frame that I think should deal with the navigation, so my thinking is the NavigationService class should delegate to this in some way?

Can anyone supply, or point me in the direction of a WPF implementation of NavigationService class using a frame for me to understand it better? So far my searching has not produced anything for WPF, just stuff tailored to Silverlight which I no nothing about.

Like I say I'm just starting to get to grips with this MVVM stuff.

Best Answer

MvvmLight doesn't provide an implementation of the INavigationService for WPF. This is because there is no standard navigation mechanism available in WPF as Laurent Bugnion - the creator of MvvmLight - has stated here: http://blog.galasoft.ch/posts/2014/10/announcing-mvvm-light-v5-for-windows-and-xamarin/

The Frame control has a NavigationService property. There is an example of how you could implement the INavigationInterface in WPF available here:

MVVM Light 5.0: How to use the Navigation service

Related Topic