JournalEntry Class

Represents an entry in either back or forward navigation history.

Namespace:  System.Windows.Navigation
Assembly:  PresentationFramework (in PresentationFramework.dll)

[SerializableAttribute]
public class JournalEntry : DependencyObject, 
	ISerializable
You cannot directly create an instance of this class in XAML.

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:

Likewise, an entry for the current item is added to forward navigation history before a back navigation occurs, which happens when:

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.");
    }
}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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.

.NET Framework

Supported in: 3.5, 3.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft