In most cases navigation between pages within an application will occur based upon some user input, for example clicking a button. In MVVM applications this is usually performed by the button data-binding to a command on the view-model (i.e. an implementation of the ICommand interface). Whilst you can easily write your own navigation commands using the DelegateCommand class, the Okra App Framework also provides dedicated commands for typical navigation scenarios.
The INavigationBase.GetNavigateToCommand(…) extension method returns a command that will navigate to the specified page. Optionally, a parameter may also be provided. In general you use the navigation commands as follows,
Note that the GoToPage2Command is defined as a public property, and initialized in the view-model constructor. You can then bind a button to this command in your XAML as follows,
In addition to navigating to new pages, the Okra App Framework provides a INavigationBase.GetGoBackCommand() extension method, which is generally bound to the page’s back button. In addition, this will automatically disable any bound buttons if the user is at the start of the navigation stack.