When navigating throughout your Prism for Xamarin.Forms applications, it is often required to pass parameters from one View to another.  Prism allows you to pass navigation parameters with three simple steps:

1. Create the navigation parameters
2. Get the navigation parameters
3. Read the navigation parameter values

Passing parameters to the next View/ViewModel can be done using an overload of the INavigationService.NavigateAsync method. This overload accepts a NavigationParameters object that can be used to supply data to the next View. The NavigationParameters object can accept any arbitrary object as a value.

Getting the navigation parameters from the target View/ViewModel is done by implementing the INavigationAware interface. The OnNavigatedFrom, OnNavigatingTo, and OnNavigatedTo methods each represent the different phases of the navigation process and expose the INavigationParameters object to you.

You read the INavigationParameters values by using either the index of the collection, the GetValue/GetValues method, or by using the TryGetValue method.

Twitter: https://twitter.com/brianlagunas
Blog: https://brianlagunas.com
GitHub: https://github.com/brianlagunas

Prism Library: http://prismlibrary.github.io/
Become a Patron: https://www.patreon.com/prismlibrary

Visit our Sponsor: https://bit.ly/prism-infragistics

Brian Lagunas

View all posts

Follow Me

Follow me on Twitter, subscribe to my YouTube channel, and watch me stream live on Twitch.