Instead of sending a message, you can pass a parameter in a call to the NavigationServicesEx.Navigate method.
This blog post by Marco Minerva advises connecting to the Frame_Navigating event (which is missing from the ServiceEx vanilla navigation class) to access the argument the destination page is being moved to.
Create the INavigable interface described in the blog:
public interface INavigable { Task OnNavigatedToAsync(object parameter, NavigationMode mode); void OnNavigatingFrom(NavigatingCancelEventArgs e); void OnNavigatedFrom(); }
Add a handler for the Frame.Navigating event in the NavigationServicesEx class (with additional fixtures, see the blog), then implement the INavigable interface in your ViewModels.
Then you can access the parameter that you passed in your navigation call:
NavigationServiceEx.Navigate(typeof(DestinationPage).FullName, yourParameter);
In the OnNavigatedToAsync method that you implement in your ViewModel:
public Task OnNavigatedToAsync(object parameter, NavigationMode mode) { if (parameter != null) { YourThing thing = parameter as YourThing; this.UseYourThing(thing); } return Task.CompletedTask; }
source share