Navigation in Windows 8 Metro Style Applications

Dec 9, 2011 at 8:30 AM

Hi,

I watched your Deep Dive MVVM MIX 11 session and then I looked at the NavigationService sample for Silverlight 4.
In your sample you create an instance of the target ViewModel and then register it in the IOC container. Then, in the target view you override OnNavigatedTo method, get the instance of the viewmodel from the IOC container and set it to the datacontext of view.

I'm trying MVVM Light Toolkit for Windows 8 and I am wondering which is the best way to pass a parameter when navigating from a view to another since the Frame control allows me to pass a parameter when navigating.

My idea is to add a Navigate method to INavigationService interface that accepts also a parameter of type object.
Then I call this new method to navigate to my target view without registering the target viewmodel in the IOC.
Then I override OnNavigatedTo in target view, create an instance of the viewmodel and set it as datacontext of the view.

What do you think?

Dec 11, 2011 at 7:34 AM
Edited Dec 11, 2011 at 9:12 AM

Hi,

I created a simple navigation application to explain which is my idea.

You can download the sample here:

https://skydrive.live.com/redir.aspx?cid=9254ccafce7ee400&resid=9254CCAFCE7EE400!291&parid=9254CCAFCE7EE400!288

A problem I see in my solution is that in each view I have to override OnNavigatedTo and OnNavigatedFrom methods and call ViewModel methods.

Aug 6, 2012 at 12:27 PM

Do you know how to implement state handling in windows 8 using mvvmlight. ie i navigated from A -> B . then terminated. Activate the app and navigate to B and go back similar thing in windows 8