Pass parameters from ConfirmNavigationRequest to NavigationService

Topics: Prism v4 - WPF 4
May 27, 2012 at 7:36 AM

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)
.Parameters.Add("Count", _verificationCount.ToString());

A Navigation Broker that Needs To Access the Passed Parameters

    // Some method
.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)
} else
Debug.WriteLine("Navigation Cancelled");
Debug.WriteLine("Navigation Error");                

How to Access Parameter Through Region or NavigationService, Outside ViewModel?

  • I cannot find a way to access NavigationContext through NavigationService or Region?
  • I also tried this _region.NavigationService.Journal.CurrentEntry.Uri.OriginalString but it did not show any query information, just the registered View string name
May 28, 2012 at 5:20 PM


Based on my understanding of your scenario you could access the passed parameters from the NavigationResult object in your NavigationCallback method, as the NavigationResult class defines properties that provide information about the navigation operation. Among these properties you could find the Context property which provides access to the NavigationContext and the parameters it contains.

For example you could access your parameter like this:

I hope you find this useful,

Agustin Adami

May 31, 2012 at 9:31 AM

That seems to be spot on! I'll try it, thanks!