I have a viewmodel that implements IConfirmNavigationRequest and I need to pass information from this viewmodel to a navigation broker class that I have, which is not coupled to any specific views or viewmodels.
Instead the navigation broker class has access to the IRegion of interest as well as to the IRegionNavigationService.
ViewModel Adding Parameters to Uri
public override void ConfirmNavigationRequest(NavigationContext navigationContext,
Action<bool> continuationCallback)
{
_verificationCount++;
navigationContext.Parameters.Add("Count", _verificationCount.ToString());
continuationCallback(Verify());
}
A Navigation Broker that Needs To Access the Passed Parameters
// Some method
_region.RequestNavigate(new Uri(_nextView, UriKind.Relative), NavigationCallback);
private void NavigationCallback(NavigationResult navigationResult)
{
if (navigationResult.Error == null)
{
if (navigationResult.Result == true)
{
// Need to evaluate the Count argument here
// int count = ...
// if (count < 5)
QueueNextView();
} else
{
Debug.WriteLine("Navigation Cancelled");
}
}
else
{
Debug.WriteLine("Navigation Error");
}
}
How to Access Parameter Through Region or NavigationService, Outside ViewModel?
- I cannot find a way to access
NavigationContextthroughNavigationServiceorRegion? - I also tried this
_region.NavigationService.Journal.CurrentEntry.Uri.OriginalStringbut it did not show any query information, just the registered View string name
Agustin Adami provided the answer here: