Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
JournalEntry Class
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
JournalEntry Class

Represents an entry in either back or forward navigation history.

Namespace:  System.Windows.Navigation
Assembly:  PresentationFramework (in PresentationFramework.dll)
Visual Basic (Declaration)
<SerializableAttribute> _
Public Class JournalEntry _
    Inherits DependencyObject _
    Implements ISerializable
Visual Basic (Usage)
Dim instance As JournalEntry
C#
[SerializableAttribute]
public class JournalEntry : DependencyObject, 
    ISerializable
Visual C++
[SerializableAttribute]
public ref class JournalEntry : public DependencyObject, 
    ISerializable
JScript
public class JournalEntry extends DependencyObject implements ISerializable
XAML
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.

C#
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..::.Object
  System.Windows.Threading..::.DispatcherObject
    System.Windows..::.DependencyObject
      System.Windows.Navigation..::.JournalEntry
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
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Navigating to a JournalEntry from the back/forward stack      Chango V. - MSFT   |   Edit   |   Show History

The framework uses JournalEntry objects to navigate to pages on the back or forward navigation stack. To the user, this is available through the navigation drop-down menu (part of the "navigation chrome", as we call it). But there is no public API that lets you directly navigate to a select JournalEntry, once you have a reference to the object. Here's how this can be accomplished in a way that simulates what happens through the UI:

IEnumerator backStackEnum = frame.BackStack.GetEnumerator();
backStackEnum.MoveNext();
// [Find the JournalEntry you want to navigate to...]
JournalEntry je = (JournalEntry)backStackEnum.Current;
FrameworkElement holder = new FrameworkElement();
holder.DataContext = je;
NavigationCommands.NavigateJournal.Execute(holder, frame); // Instead of frame, you could pass a Page object or an element within the page such as a Button. The command will bubble to the containing Frame or the top NavigationWindow.

Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker