windows-phone-8navigationmvvm-lightcimbalino

WP MVVM Navigation OnNavigatedTO


I am starting to implement MVVM in my application and got an issue of knowing when the user navigated to the view.

To navigate between views, I can just use the navigationService.Navigate(...);

How do I check when I navigated to the view? May I use the event navigationService.Navigated?

Is there no other method I can use like OnNavigatedTo that the page itself provide?


Solution

  • Thanks for the answers provided. Both were helpful over a period of time until I decided to create a custom implementation of the navigation service that has been created by a few people. I then made a contribution to the Cimbalino toolkit to suggest this and it has been introduced a while back.

    I my personal opinion, that solves my issue the best. Have a look at the navigation service in there. The Navigated event pretty much solves my issue I had.

    https://github.com/Cimbalino/Cimbalino-Toolkit

    It basically comes down to this (in your viewmodel):

    _navigationService.Navigated += OnNavigated;