Can I limit the number of entries in the NavigationService.Journal

Topics: Prism v4 - WPF 4
Nov 17, 2010 at 1:54 PM

I want to limit the number of entries kept in the journal stack to control memory consumption.

Is there a way to limit the the total number of Journal entries kept in a NavigationService.Journal?

Nov 17, 2010 at 9:03 PM

Hi,

There is no guidance on this topic in Prism out-of-the-box. The RegionNavigationJournal class is using two Stack<T> for supporting back/forward journaling, but capacities have not been configured, as shown below. But please, take into account that the journal contains a list of uri(s) as history.

public class RegionNavigationJournal : IRegionNavigationJournal
{
private Stack<IRegionNavigationJournalEntry> backStack = new Stack<IRegionNavigationJournalEntry>();
private Stack<IRegionNavigationJournalEntry> forwardStack = new Stack<IRegionNavigationJournalEntry>();
...
}

That said, I think that you could create your own implementation of IRegionNavigationJournal and set the capacities of your stacks. If you need guidance on how to configure the capacity of a stack, you could take a look at the following documentation section on MSDN: Stack.Stack(Int32) Constructor

Hope this helps.

Fernando Antivero
http://blogs.southworks.net/fantivero