Journal not updated when closing last view in region

Topics: Prism v4 - WPF 4
Aug 14, 2013 at 2:39 PM
I don't know if I'm doing something wrong here but this is my scenario.

I have a single active region, which views are open and closed in. So I open view1, the region has view1 in it, I then navigate to view2, a back arrow then becomes visible. On clicking back it sets keep alive to false and use journal.GoBack() method to navigate back to view1. This works fine and the journal is up to date. My problem is what to do when you close view1 and you can't go back. At the moment I set keepalive to false and deactivate view 1. But this doesn't seem to update the journal?? How can I get it so it does update the journal?

Am I correct in that I should deactivate to close a view if I can't go back? And if so why doesn't this sort out the journal? How would I best sort out the journal?
Developer
Aug 15, 2013 at 6:20 PM
Hi James,

The navigation journal used in Prism works similar to the navigation journal of a web browser. It stores the URI of the previous pages (or in this case views) rather that page itself. Hence, when you use the "go back" functionality in Prism's navigation API, it does not actually switch to the previous page. Instead it just performs a navigation request using the previous URI and as with a common navigation request, it might navigate to an existing view or create a new one if no one exists in the region. Likewise, as you cannot remove a "previous URI" from the navigation journal of a web browser, Prism's navigation journal does not provide any functionality to remove an specific URI from its navigation history (although it does provide a Clear method to discard the entire navigation history.)

However, if you need to implement this feature, I believe you will need to modify or create your own RegionNavigationJournal and RegionNavigationJournalEntry implementations. Then, for example, you could raise an event when erasing a view to remove any related URIs of said view from the navigation history.

You can find more information on the following Prism chapter section:
On the other hand, it would be useful if you could explain in further detail why you want to remove a view for the navigation journal, so that we can have a better understanding of your scenario and help you find other possibles approaches to tackle the problem.

I hope this helps,

Damian Cherubini
http://blogs.southworks.net/dcherubini
Aug 16, 2013 at 8:02 AM
Ok thank you. I understand that, I will just deactivate and clear the journal which solves most of my issues.

My main issue is that the ConfirmNavigation doesn't fire when I close, because NavigateFrom isn't used. I have forced this to fire at present at this point in time. I guess this is because I am using it a little differently than was designed.