JournalEntry Class
Represents an entry in either back or forward navigation history.
Assembly: PresentationFramework (in PresentationFramework.dll)
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 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.