Navigate to previous view in PRISM

Topics: Prism v4 - WPF 4
Jul 28, 2012 at 8:20 AM
Edited Jul 28, 2012 at 8:22 AM


I'm wondering how navigate to previously displayed view in PRISM? If i save each Uri in a stack  then how i can recognize same opened views? Uris are same! let me explain it with a sample:

User clicks on "new document" button. view navigates to new document.


regionManager.NavigateRequest("MainRegion", "NewDocument");


user types some text on textbox in that view, and then clicks on "new document" button. again this line gets execute:


regionManager.NavigateRequest("MainRegion", "NewDocument");


by now there are two "NewDocument" views in TabControl. but how we can identify each of views? 

Jul 30, 2012 at 2:21 PM


Based on my understanding of your scenario, I believe you could benefit from the use of the the IsNavigationTarget method on the INavigationAware interface.

The IsNavigationTarget method allows an existing (displayed) view or view model to indicate whether it is able to handle the navigation request or not. Hence, it could be useful if you need to determine if an existing view will handle the navigation operation or when navigating to a view that already exists. For example, the implementation of the IsNavigationTarget method can use the NavigationContext parameter to determine which view you want to navigate.

You can find more information about this in the following sections of the Navigation chapter in the Prism documentation:

Also, one thing you should consider, is that by default in Prism, when registering views in the container with a contract name that differs from the view type Name or FullName, no matches will be found, and a new instance will be retrieved from the container. Hence, if you want to be able to navigate to an existing view, the view's name in the navigation URI should be the same as the actual target type's short type name.

I hope you find this useful,

Agustin Adami