This project is read-only.

Navigation

StyleMVVM supports two forms of navigation. The first being the traditional Frame navigation and the second being Region navigation (similar to Prism). You can use both with in an app but it is probably best to choose one navigation style and stick to it.

Frame Navigation

This is the traditional navigation scheme based upon the Frame control. If you are using one of the provided project templates (excluding the region template) a frame is created at startup and set as the main content for the application window. The Frame class can be navigated manually or using the provided INavigationService.

INavigationService

The INavigationService is available as a global service or as a local instance. When used as a global service the navigation service will navigate the main window Frame. If used locally in the case of a PageViewModel the frame that the page is located in will be used for navigation (this is important for nested frames).

INavigatingPage & INavigationViewModel

The INavigatingPage and INavigationViewModel interfaces work in tandem to wire your ViewModel to your page. The INavigatingPage interface has three events centered around the pages life cycle, and need to be fired when loaded, navigating and navigated is raised within the page (if you inherit from NavigatingPage or LayoutAwarePage this will be handled for you). ViewModels that wish to participate in the Page life cycle need to implement the INavigationViewModel interface, as the page cycles through its different states each method will be called to alert the ViewModel of the change (if you inherit from PageViewModel this will all be handled for you). Below is an example of Navigating a page from within a ViewModel.

    public class SomeViewModel : PageViewModel
    {
       public void NavigateByName()
       {
          Navigation.Navigate("NewPageName");
       }

       public void NavigateWithParameter()
       {
           object navigationParameter =  "NavigationParameter";

           Navigation.Navigate("DifferentPageName", navigationParameter );
       }
    }

Region Navigation

TBD

Last edited Nov 3, 2012 at 5:38 PM by ipjohnson123, version 4

Comments

No comments yet.