This project has moved and is read-only. For the latest updates, please go here.

WP7 and NavigationService.

May 16, 2010 at 5:59 AM

Got any suggestions to be able to get navigation service instance to the view model?  I was thinking of using Messenger but not sure how to wire it up... I am unfortunately still learning as I go but best way is hands on right?

I thought about overriding the OnNavigateTo() for the page in question ( I know its not pure seperation but when in need).  I don't know how to register the Messenger for the Send (aka incoming messages) to utilize the Uri once I send it.

May 16, 2010 at 4:01 PM

I got it figured out.. The link to your samples for MIX was messed up but did a little digging and got a copy, messenger is pretty cool little pattern once you know what do to with it :)


May 16, 2010 at 4:13 PM


What links did you have issues with?




May 18, 2010 at 6:21 PM
it was someone else that posted a link on your blog that was completely wrong for the zip file had dashes not periods... So all is good.
May 20, 2010 at 3:56 AM
Edited May 20, 2010 at 3:56 AM

Thought I would share what I found out today for all to gain access to the Navigation Service in WP7..

So in your viewmodel you can get this usability via creating a variable as such:

PhoneApplicationFrame root = Application.Current.RootVisual as PhoneApplicationFrame;

this actually has to happen in each click event you want to respond to in your viewmodel this is actually quite nice since it gives you access to the Navigate() method of the NavigationService.

root.Navigate(new Uri("/View/YourView.xaml"));


This doesn't require any override of the OnNavigateTo() method of the navservice...




Oct 16, 2010 at 10:22 PM

Hi All,

I am considering which approach to use in my WP7 app (no reference to the navigationservice) and there seems to be a lot of different ways of doing it:

  1.             Use messenging - raise message in VM -
  2.             Raise an event in the VM and subscribe to it
  3.             Use the method like this -  ((PhoneApplicationFrame)App.Current.RootVisual).Navigate(new Uri("/AboutPage.xaml", UriKind.Relative)); - //
  4.             Make a ref in the VM to your V - not cool!
  5.             Other solutions: Interface -
  6.             Other controller -   or

Is Morgan's solution considered "bad practise" for MMVM? It is the simplest and quickest.

Messenging with MVVM Light seems to be considered the best one but I want to KISS.