JournalEntry Class
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
Windows Presentation Foundation (WPF) implements a navigation history service that stores one entry for each piece of content that has been previously navigated to, just like navigation history in Microsoft Internet Explorer. Navigation history comprises two stacks, one that remembers back navigation history, and one that remembers forward navigation history.
An entry for the current item is added to back navigation history when a forward navigation occurs. This occurs in the following situations.
-
The Navigate method is called (NavigationService.Navigate, NavigationWindow.Navigate, Frame.Navigate).
-
The GoForward method is called (NavigationService.GoForward, NavigationWindow.GoForward, Frame.GoForward).
-
The forward button on the navigation UI that is displayed from the current navigator (XBAP, NavigationWindow, Frame).
Likewise, an entry for the current item is added to forward navigation history before a back navigation occurs, which happens when:
-
The GoBack method is called (NavigationService.GoBack, NavigationWindow.GoBack, Frame.GoBack).
-
The back button on the navigation UI that is displayed from the current navigator (XBAP, NavigationWindow, Frame).
Each entry in back and forward navigation history is an instance of the JournalEntry class.
Each JournalEntry object encapsulates information about a particular navigation, including a name for the entry (Name), whether the entry is kept alive (KeepAlive) and the uniform resource identifier (URI) for the content that is navigated to (Source).
You can retrieve all the JournalEntry objects in back navigation history by enumerating the NavigationWindow.BackStack or Frame.BackStack properties. For forward navigation history, you can retrieve all the JournalEntry objects by enumerating the NavigationWindow.ForwardStack or Frame.ForwardStack properties.
If you need to remove the most recent JournalEntry object from back navigation history, to prevent navigation to it, for example, you can call the RemoveBackEntry method (NavigationService.RemoveBackEntry, NavigationWindow.RemoveBackEntry, Frame.RemoveBackEntry), which removes the JournalEntry object and returns a reference to it.
You cannot add JournalEntry objects to navigation history, however, because you can neither instantiate nor derive from JournalEntry, and because no type implements a member to do so. However, you can add custom CustomContentState objects to back navigation history by calling the AddBackEntry method (AddBackEntry, AddBackEntry,AddBackEntry); NavigationService adds the CustomContentState object to an internally-created JournalEntry object, which is then added to the back navigation history.
For an example that uses CustomContentState to remember a single set of state across page instances, see Remember A Single Set of State Across Page Instances.
For an example that uses CustomContentState to remember multiple sets of state for a single page instance, see Remember Multiple Sets of State Per Page Instance.
The following example shows how to retrieve the most recent JournalEntry object from the back navigation stack to get the Name and Source property values.
void removeJournalEntryButton_Click(object sender, RoutedEventArgs e) { // If there are journal entries on the back navigation stack if (this.NavigationService.CanGoBack) { // Remove and get the most recent entry on the back navigation stack JournalEntry journalEntry = this.NavigationService.RemoveBackEntry(); string name = journalEntry.Name; string uri = journalEntry.Source.OriginalString; MessageBox.Show(name + " [" + uri + "] removed from back navigation."); } }
System.Windows.Threading.DispatcherObject
System.Windows.DependencyObject
System.Windows.Navigation.JournalEntry
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.