11 responses

  1. John Vance
    February 23, 2014
  2. KurianOfBorg
    May 10, 2013

    Accessing a global navigator outside the view model is a violation. If the view model contains functions which require navigation (such as a PageFunction to retrieve something) then the NavigationService to be used must be passed in. Navigation to other unrelated pages should be done from just the view.

  3. Geert van Horrik
    February 17, 2012

    This can’t be called MVVM. Why reference views in the view models? It is wrong!

    You should write a service that takes care of this that you can mock (or write a test implementation) to make sure that the VM behaves like it should. I think it is wrong to post blogs like this because everyone believes this is the correct approach…

    • CB
      February 19, 2012

      From my understanding and use of the MVVMLight toolkit, VMs are not referencing Views at all, but merely sending messages that a View might listen for and act on.

  4. Jonathan Allen
    January 17, 2012

    A global navigator object sounds just as bad, either way you are accessing a global.

    My view-model accepts an INavigator object as its constructor. For testing I pass in a SimpleNavigator. For the real app I use a “PhoneApplicationFrameNavigator”, which is just a simple wrapper around a PhoneApplicationFrame.

    The code is in the Granite project on Codeplex. Look for “Granite Xaml” library.

  5. Ihor Bats
    January 17, 2012

    Yes guys, it worth but if you have application only with a few pages it’s not a problem to use this approach…

  6. Rob S.
    January 17, 2012

    Doesn’t that kill unit-testability? I really prefer having a global navigator object that I can use to handle navigation messages.

  7. Erno
    January 17, 2012

    I prefer to use a NavigationMap because otherwise you’d be forced to check all the Uri’s scattered though out the application when you change the folders and/or names of the views.

    • Kahuna
      April 30, 2013

      Hi Erno,

      Would you be so kind and post an example of such a NavigationMap? I’d be interested in your way of implementation.

      Thanks a lot!

Leave a Reply

 

 

 

Back to top
mobile desktop