Sie sind auf Seite 1von 196

Contents

System.Windows.Navigation
BaseUriHelper
BaseUriProperty
GetBaseUri
CustomContentState
CustomContentState
JournalEntryName
Replay
FragmentNavigationEventArgs
Fragment
Handled
Navigator
FragmentNavigationEventHandler
IProvideCustomContentState
GetContentState
JournalEntry
CustomContentState
GetKeepAlive
GetName
GetObjectData
JournalEntry
KeepAlive
KeepAliveProperty
Name
NameProperty
SetKeepAlive
SetName
Source
JournalEntryListConverter
Convert
ConvertBack
JournalEntryListConverter
JournalEntryPosition
JournalEntryUnifiedViewConverter
Convert
ConvertBack
GetJournalEntryPosition
JournalEntryPosition
JournalEntryPositionProperty
JournalEntryUnifiedViewConverter
SetJournalEntryPosition
JournalOwnership
LoadCompletedEventHandler
NavigatedEventHandler
NavigatingCancelEventArgs
Content
ContentStateToSave
ExtraData
IsNavigationInitiator
NavigationMode
Navigator
TargetContentState
Uri
WebRequest
NavigatingCancelEventHandler
NavigationEventArgs
Content
ExtraData
IsNavigationInitiator
Navigator
Uri
WebResponse
NavigationFailedEventArgs
Exception
ExtraData
Handled
Navigator
Uri
WebRequest
WebResponse
NavigationFailedEventHandler
NavigationMode
NavigationProgressEventArgs
BytesRead
MaxBytes
Navigator
Uri
NavigationProgressEventHandler
NavigationService
AddBackEntry
CanGoBack
CanGoForward
Content
CurrentSource
FragmentNavigation
GetNavigationService
GoBack
GoForward
LoadCompleted
Navigate
Navigated
Navigating
NavigationFailed
NavigationProgress
NavigationStopped
Refresh
RemoveBackEntry
Source
StopLoading
NavigationStoppedEventHandler
NavigationUIVisibility
NavigationWindow
AddBackEntry
AddChild
AddText
BackStack
BackStackProperty
CanGoBack
CanGoBackProperty
CanGoForward
CanGoForwardProperty
CurrentSource
ForwardStack
ForwardStackProperty
FragmentNavigation
GoBack
GoForward
IUriContext.BaseUri
LoadCompleted
Navigate
Navigated
Navigating
NavigationFailed
NavigationProgress
NavigationService
NavigationStopped
NavigationWindow
OnApplyTemplate
OnClosed
OnCreateAutomationPeer
Refresh
RemoveBackEntry
SandboxExternalContent
SandboxExternalContentProperty
ShouldSerializeContent
ShowsNavigationUI
ShowsNavigationUIProperty
Source
SourceProperty
StopLoading
PageFunction<T>
OnReturn
PageFunction<T>
Return
PageFunctionBase
PageFunctionBase
RemoveFromJournal
Start
RequestNavigateEventArgs
InvokeEventHandler
RequestNavigateEventArgs
Target
Uri
RequestNavigateEventHandler
ReturnEventArgs<T>
Result
ReturnEventArgs<T>
ReturnEventHandler<T>
System.Windows.Navigation Namespace
Provides types that support navigation, including navigating between windows and navigation journaling.

Classes
BaseUriHelper
Provides a method to resolve relative uniform resource
identifiers (URIs) with respect to the base URI of a container,
such as a Frame.

CustomContentState
CustomContentState enables the ability to navigate through
different states of a single piece of source content without
reloading the source content for each subsequent navigation.

FragmentNavigationEventArgs
Provides data for the FragmentNavigation event.

JournalEntry
Represents an entry in either back or forward navigation
history.

JournalEntryListConverter
This type or member supports the Microsoft .NET
infrastructure and is not intended to be used directly from
your code.

JournalEntryUnifiedViewConverter
JournalEntryUnifiedViewConverter merges navigation back
history and navigation forward history (as exposed by Frame
or NavigationWindow) into a single, Windows Internet
Explorer 7-style navigation menu.

NavigatingCancelEventArgs
Provides data for the Navigating event.

NavigationEventArgs
Provides data for non-cancelable navigation events, including
LoadCompleted, Navigated, and NavigationStopped.

NavigationFailedEventArgs
Provides data for the NavigationFailed event.

NavigationProgressEventArgs
Provides data for the NavigationProgress and
NavigationProgress events.

NavigationService
Contains methods, properties, and events to support
navigation.
NavigationWindow
Represents a window that supports content navigation.

PageFunction<T>
Represents a special type of page that allows you to treat
navigation to a page in a similar fashion to calling a method.

PageFunctionBase
An abstract base class that is the parent of all page function
classes.

RequestNavigateEventArgs
Provides data for the RequestNavigate event.

ReturnEventArgs<T>
Provides data for the Return event.

Interfaces
IProvideCustomContentState
Implemented by a class that needs to add custom state to the
navigation history entry for content before the content is
navigated away from.

Enums
JournalEntryPosition
Specifies the position in navigation history of a piece of
content with respect to current content. JournalEntryPosition
is used by JournalEntryUnifiedViewConverter.

JournalOwnership
Specifies whether a Frame uses its own journal.
JournalOwnership is used by the JournalOwnership property.

NavigationMode
Specifies the type of navigation that is taking place
NavigationMode is used by the NavigationMode property.

NavigationUIVisibility
Specifies whether a Frame displays its navigation chrome.
NavigationUIVisibility is used by the NavigationUIVisibility
property.

Delegates
FragmentNavigationEventHandler
Represents the method that will handle
FragmentNavigation events.
LoadCompletedEventHandler
Represents the method that will handle LoadCompleted
events.

NavigatedEventHandler
Represents the method that will handle Navigated events.

NavigatingCancelEventHandler
Represents the method that will handle Navigating events.

NavigationFailedEventHandler
Represents the method that will handle NavigationFailed
events.

NavigationProgressEventHandler
Represents the method that will handle
NavigationProgress events.

NavigationStoppedEventHandler
Represents the method that will handle
NavigationStopped events.

RequestNavigateEventHandler
Represents the method that will handle the RequestNavigate
routed event of the Hyperlink class.

ReturnEventHandler<T>
Represents the method that will handle the Return event of
the PageFunction<T> class.
BaseUriHelper BaseUriHelper Class
Provides a method to resolve relative uniform resource identifiers (URIs) with respect to the base URI of a container,
such as a Frame.

D eclaration
public static class BaseUriHelper
type BaseUriHelper = class

I nheritance H ierarchy
Object Object

Fields
BaseUriProperty
BaseUriProperty

Identifies the BaseUri attached property.

Methods
GetBaseUri(DependencyObject)
GetBaseUri(DependencyObject)

Gets the value of the BaseUri for a specified UIElement.


BaseUriHelper.BaseUriProperty BaseUriHelper.BaseUri
Property
I n this Article
Identifies the BaseUri attached property.

public static readonly System.Windows.DependencyProperty BaseUriProperty;


staticval mutable BaseUriProperty : System.Windows.DependencyProperty

Returns
DependencyProperty DependencyProperty
BaseUriHelper.GetBaseUri BaseUriHelper.GetBaseUri
I n this Article
Gets the value of the BaseUri for a specified UIElement.

[System.Security.SecurityCritical]
public static Uri GetBaseUri (System.Windows.DependencyObject element);
static member GetBaseUri : System.Windows.DependencyObject -> Uri

Parameters
element DependencyObject DependencyObject
The element from which the property value is read.
Returns
Uri Uri
The base URI of a given element.
Attributes SecurityCriticalAttribute
Exceptions
ArgumentNullException ArgumentNullException
element is null .

Remarks
Use this method to get the IUriContext.BaseUri property if it is implemented or the BaseUri attached property if is set
on an element. GetBaseUri will traverse the parent elements of element to search for the nearest BaseUri (IUriContext
or attached property).
CustomContentState CustomContentState Class
CustomContentState enables the ability to navigate through different states of a single piece of source content without
reloading the source content for each subsequent navigation.

D eclaration
[System.Serializable]
public abstract class CustomContentState
type CustomContentState = class

I nheritance H ierarchy
Object Object

Remarks
By default, NavigationService does not store an instance of a content object in navigation history. Instead,
NavigationService creates a new instance of the content object each time it is navigated to by using navigation history.
This behavior is designed to avoid excessive memory consumption when large numbers and large pieces of content
are being navigated to. Consequently, the state of the content is not remembered from one navigation to the next.
However, WPF provides the ability to associate a piece of custom state with the navigation history entry for a piece of
content.
Custom state that is associated with a navigation history entry must be a class that derives from CustomContentState.
You associate a CustomContentState object with a navigation history entry by using one of the following techniques:
Calling AddBackEntry:
NavigationService.AddBackEntry
NavigationWindow.AddBackEntry
Frame.AddBackEntry.
Setting NavigatingCancelEventArgs.Content when one of the following events are raised:
NavigationService.Navigating
NavigationWindow.Navigating
Frame.Navigating
NavigationWindow.Navigating
By implementing IProvideCustomContentState on the class that wants custom state to be associated with it.
Note

If you call the AddBackEntry method, you must handle the Navigating event or implement
IProvideCustomContentState.
When the navigation history entry is navigated to, WPF checks to see if a custom CustomContentState object is
associated with it. If so, it calls Replay to allow the custom CustomContentState object to apply the state it remembered
from the previous navigation.
A custom CustomContentState class can override JournalEntryName to change the name that appears for the
navigation history entry to which the CustomContentState object is associated. The value that JournalEntryName
returns is visible from the navigation UI of the various navigators (Internet Explorer 7, NavigationWindow, Frame).
A class that derives from CustomContentState must be serializable, which means it must at least be augmented with
SerializableAttribute, and optionally implement ISerializable.
Im p o rt a nt

When you store information in custom content state, you cannot store any references to the instance of the page for
which you are remembering state if don't want the content to be retained in memory. This prevents WPF from
releasing the page instance, and defeats the purpose of the default navigation history behavior. If you must do this,
consider using KeepAlive instead.

Constructors
CustomContentState()
CustomContentState()

Initializes a new instance of the CustomContentState class.

Properties
JournalEntryName
JournalEntryName

The name for the content that is stored in navigation history. The value of JournalEntryName is displayed from
NavigationWindow, Frame, and Windows Internet Explorer 7 navigation UI.

Methods
Replay(NavigationService, NavigationMode)
Replay(NavigationService, NavigationMode)

Called to reapply state to a piece of content when navigation occurs.

See Also
NavigationService NavigationService
CustomContentState
I n this Article
Initializes a new instance of the CustomContentState class.
protected CustomContentState ();
CustomContentState.JournalEntryName CustomContent
State.JournalEntryName
I n this Article
The name for the content that is stored in navigation history. The value of JournalEntryName is displayed from
NavigationWindow, Frame, and Windows Internet Explorer 7 navigation UI.
public virtual string JournalEntryName { get; }
member this.JournalEntryName : string

Returns
String String
The String name of the content that is stored in navigation history.

Remarks
Entries stored in back and forward navigation history are typically available from the back and forward drop down
navigation buttons on the navigation UI of the host navigator, including NavigationWindow, Frame, or Windows
Internet Explorer 7.
JournalEntryName is the String value that is displayed in a navigation history drop down list.
JournalEntryName does not have to be overridden; if not, the following pieces of data are used to automatically
construct a navigation history entry name, in order of precedence:
Title.
WindowTitle and the uniform resource identifier (URI) for the current page
The uniform resource identifier (URI) for the current page.
CustomContentState.Replay CustomContentState.Replay
I n this Article
Called to reapply state to a piece of content when navigation occurs.
public abstract void Replay (System.Windows.Navigation.NavigationService navigationService,
System.Windows.Navigation.NavigationMode mode);
abstract member Replay : System.Windows.Navigation.NavigationService *
System.Windows.Navigation.NavigationMode -> unit

Parameters
navigationService NavigationService NavigationService
The NavigationService owned by the navigator responsible for the content to which this CustomContentState is being
applied.
mode NavigationMode NavigationMode
A NavigationMode that specifies how the content to which the CustomContentState is being applied was navigated to.

Remarks
Replay is called when an item in navigation history that has an associated CustomContentState object is navigated to.
When deriving from the abstract CustomContentState class, Replay must be overridden, although the override
implementation need only call the base Replay method.
FragmentNavigationEventArgs FragmentNavigation
EventArgs Class
Provides data for the FragmentNavigation event.

D eclaration
public class FragmentNavigationEventArgs : EventArgs
type FragmentNavigationEventArgs = class
inherit EventArgs

I nheritance H ierarchy
Object Object
EventArgs EventArgs

Remarks
T These event arguments contain information about the content fragment that is being navigated to, and are passed to
handlers of the FragmentNavigation event, which is implemented by the following:
NavigationService.FragmentNavigation
NavigationWindow.FragmentNavigation
Frame.FragmentNavigation
Application.FragmentNavigation
By default, a content fragment is content that is contained by a named UIElement, which is a UIElement whose Name
attribute is set, e.g.:
<TextBlock Name="FragmentName">...</TextBlock>

You navigate to a XAML fragment by providing a URI with a suffix in the following format:
#FragmentName
The following shows an example of a URI that refers to a content fragment:
http://www.microsoft.com/targetpage.xaml#FragmentName
You can handle the FragmentNavigation event and use FragmentNavigationEventArgs to implement a custom
content fragment handling implementation.

Properties
Fragment
Fragment

Gets the uniform resource identifier (URI) fragment.

Handled
Handled
Gets or sets a value that indicates whether the fragment navigation has been handled.

Navigator
Navigator

The navigator that raised the FragmentNavigation event.


FragmentNavigationEventArgs.Fragment Fragment
NavigationEventArgs.Fragment
I n this Article
Gets the uniform resource identifier (URI) fragment.

public string Fragment { get; }


member this.Fragment : string

Returns
String String
The URI fragment. If you set the property to an empty string, the top of the content will be navigated to by default.
FragmentNavigationEventArgs.Handled Fragment
NavigationEventArgs.Handled
I n this Article
Gets or sets a value that indicates whether the fragment navigation has been handled.

public bool Handled { get; set; }


member this.Handled : bool with get, set

Returns
Boolean Boolean
true if the navigation has been handled; otherwise, false .

Remarks
If Handled is set to false , the system attempts to find an element with the name of the fragment and bring it into
view.
When you handle the FragmentNavigation event and use FragmentNavigationEventArgs to implement a custom
content fragment handling implementation, you need to set Handled is set to true to override the default behavior.
FragmentNavigationEventArgs.Navigator Fragment
NavigationEventArgs.Navigator
I n this Article
The navigator that raised the FragmentNavigation event.

public object Navigator { get; }


member this.Navigator : obj

Returns
Object Object
A Object that refers to the navigator (Internet Explorer, NavigationWindow, Frame.) that is navigating to the content
fragment.
FragmentNavigationEventHandler FragmentNavigation
EventHandler Delegate
Represents the method that will handle FragmentNavigation events.

D eclaration
public delegate void FragmentNavigationEventHandler(object sender, FragmentNavigationEventArgs
e);
type FragmentNavigationEventHandler = delegate of obj * FragmentNavigationEventArgs -> unit

I nheritance H ierarchy
Object Object
Delegate Delegate

Remarks
This event handler is used for the following events:
NavigationService.FragmentNavigation
NavigationWindow.FragmentNavigation
Frame.FragmentNavigation
Application.FragmentNavigation
IProvideCustomContentState IProvideCustomContent
State Interface
Implemented by a class that needs to add custom state to the navigation history entry for content before the content is
navigated away from.

D eclaration
public interface IProvideCustomContentState
type IProvideCustomContentState = interface

I nheritance H ierarchy
None

Remarks
IProvideCustomContentState allows you to associate a piece of custom state, implemented as a custom
CustomContentState class, with the navigation history entry for content that has been navigated away from.
Custom state can also be associated in this way by using the following:
Calling AddBackEntry:
NavigationService.AddBackEntry
NavigationWindow.AddBackEntry
Frame.AddBackEntry.
Setting NavigatingCancelEventArgs.Content when one of the following events are raised:
NavigationService.Navigating
NavigationWindow.Navigating
Frame.Navigating
NavigationWindow.Navigating
You must implement IProvideCustomContentState when you add custom state to navigation history by calling
AddBackEntry, otherwise navigation history will not function correctly; consider the following steps:
1. AddBackEntry is called to associate a custom state with the current content.
2. The navigation history entry is navigated back to, and the Replay method of the custom state is called, and the state is
applied to the content.
3. The previous content is navigated to in forward navigation history.
4. The navigation history entry is navigated back to, but the custom state has not been retained since the last time the
navigation history entry it was associated with was navigated to.
This is the default behavior because the state that is initially recorded in custom state may change after it was added to
navigation history. If the custom state object is navigated back to and its state is applied, before some aspect about the
state changes before the entry in navigation history is navigated to, the change in state cannot be reflected in the
custom state object. Furthermore, AddBackEntry can't be explicitly called to add a new custom state object that reflects
the state changes. Consequently, to ensure the current state for a particular navigation is always stored in navigation
history, GetContentState is called.
Im p o rt a nt

When you store information in custom content state, you cannot store any references to the instance of the page for
which you are remembering state. This prevents WPF from releasing the page instance, and defeats the purpose of the
default navigation history behavior. If you must do this, you might consider using KeepAlive instead.

Methods
GetContentState()
GetContentState()

Returns an instance of a custom state class that is to be associated with content in navigation history.
IProvideCustomContentState.GetContentState IProvide
CustomContentState.GetContentState
I n this Article
Returns an instance of a custom state class that is to be associated with content in navigation history.

public System.Windows.Navigation.CustomContentState GetContentState ();


abstract member GetContentState : unit -> System.Windows.Navigation.CustomContentState

Returns
CustomContentState CustomContentState
An instance of a custom CustomContentState class that is to be associated with content in navigation history.
JournalEntry JournalEntry Class
Represents an entry in either back or forward navigation history.

D eclaration
[System.Serializable]
public class JournalEntry : System.Windows.DependencyObject,
System.Runtime.Serialization.ISerializable
type JournalEntry = class
inherit DependencyObject
interface ISerializable

I nheritance H ierarchy
Object Object
DispatcherObject DispatcherObject
DependencyObject DependencyObject

Remarks
Windows Presentation Foundation 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.

Constructors
JournalEntry(SerializationInfo, StreamingContext)
JournalEntry(SerializationInfo, StreamingContext)

Initializes a new instance of the JournalEntry class.

Fields
KeepAliveProperty
KeepAliveProperty

Identifies the KeepAlive attached property.

NameProperty
NameProperty

Identifies the Name attached property.

Properties
CustomContentState
CustomContentState

Gets or sets the CustomContentState object that is associated with this journal entry.

Name
Name

Gets or sets the name of the journal entry.

Source
Source

Gets or sets the URI of the content that was navigated to.

KeepAlive
KeepAlive

Gets or sets a value that indicates whether the content of a journal entry is either retained or re-created when
navigated to in navigation history.

Methods
GetKeepAlive(DependencyObject)
GetKeepAlive(DependencyObject)

Returns the KeepAlive attached property of the journal entry for the specified element.

GetName(DependencyObject)
GetName(DependencyObject)

Gets the Name attached property of the journal entry for the specified element.

GetObjectData(SerializationInfo, StreamingContext)
GetObjectData(SerializationInfo, StreamingContext)

Called when this object is serialized.

SetKeepAlive(DependencyObject, Boolean)
SetKeepAlive(DependencyObject, Boolean)

Sets the KeepAlive attached property of the specified element.

SetName(DependencyObject, String)
SetName(DependencyObject, String)

Sets the Name attached property of the specified element.


JournalEntry.CustomContentState JournalEntry.Custom
ContentState
I n this Article
Gets or sets the CustomContentState object that is associated with this journal entry.

public System.Windows.Navigation.CustomContentState CustomContentState { get; }


member this.CustomContentState : System.Windows.Navigation.CustomContentState

Returns
CustomContentState CustomContentState
The CustomContentState object that is associated with this journal entry. If one is not associated, null is returned.
JournalEntry.GetKeepAlive JournalEntry.GetKeepAlive
I n this Article
Returns the KeepAlive attached property of the journal entry for the specified element.
public static bool GetKeepAlive (System.Windows.DependencyObject dependencyObject);
static member GetKeepAlive : System.Windows.DependencyObject -> bool

Parameters
dependencyObject DependencyObject DependencyObject
The element from which to get the attached property value.
Returns
Boolean Boolean
The value of the KeepAlive attached property of the journal entry for the specified element.
See KeepAlivePropertyKeepAliveProperty
Also
JournalEntry.GetName JournalEntry.GetName
I n this Article
Gets the Name attached property of the journal entry for the specified element.
public static string GetName (System.Windows.DependencyObject dependencyObject);
static member GetName : System.Windows.DependencyObject -> string

Parameters
dependencyObject DependencyObject DependencyObject
The element from which to get the attached property value.
Returns
String String
The Name attached property of the journal entry for the specified element.
See NamePropertyNameProperty
Also
JournalEntry.GetObjectData JournalEntry.GetObjectData
I n this Article
Called when this object is serialized.
[System.Security.SecurityCritical]
public virtual void GetObjectData (System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context);
abstract member GetObjectData : System.Runtime.Serialization.SerializationInfo *
System.Runtime.Serialization.StreamingContext -> unit
override this.GetObjectData : System.Runtime.Serialization.SerializationInfo *
System.Runtime.Serialization.StreamingContext -> unit

Parameters
info SerializationInfo SerializationInfo
The data that is required to serialize the target object.
context StreamingContext StreamingContext
The streaming context.
Attributes SecurityCriticalAttribute
See ISerializableISerializable
Also
JournalEntry JournalEntry
I n this Article
Initializes a new instance of the JournalEntry class.
protected JournalEntry (System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context);
new System.Windows.Navigation.JournalEntry : System.Runtime.Serialization.SerializationInfo *
System.Runtime.Serialization.StreamingContext -> System.Windows.Navigation.JournalEntry

Parameters
info SerializationInfo SerializationInfo
The serialization information.
context StreamingContext StreamingContext
The streaming context.
JournalEntry.KeepAliveProperty JournalEntry.KeepAlive
Property
I n this Article
Identifies the KeepAlive attached property.

public static readonly System.Windows.DependencyProperty KeepAliveProperty;


staticval mutable KeepAliveProperty : System.Windows.DependencyProperty

Returns
DependencyProperty DependencyProperty
JournalEntry.Name JournalEntry.Name
I n this Article
Gets or sets the name of the journal entry.
public string Name { get; set; }
member this.Name : string with get, set

Returns
String String
The name of the journal entry.

Examples
The following example shows how to set the Name property for a Page from markup, with a XAML attached property
usage.
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
JournalEntry.Name="JournalEntry Name"
>
<!--Page Content-->
</Page>

Remarks
Content hosted by NavigationWindow, Frame, or Internet Explorer 7, display navigation UI that allows users to
navigate through back and forward navigation history. The text that is displayed for each entry in navigation history
depends on which of the following pieces of data are used to automatically construct a navigation history entry name,
in order of precedence:
The attached Name attribute.
Title.
WindowTitle and the uniform resource identifier (URI) for the current page
The uniform resource identifier (URI) for the current page.
X A ML Attribute Usage
<object JournalEntry.Name="String"/>
D ependency P roperty I nformation

Identifier field NameProperty

Metadata properties set to true None


JournalEntry.NameProperty JournalEntry.NameProperty
I n this Article
Identifies the Name attached property.
public static readonly System.Windows.DependencyProperty NameProperty;
staticval mutable NameProperty : System.Windows.DependencyProperty

Returns
DependencyProperty DependencyProperty
JournalEntry.SetKeepAlive JournalEntry.SetKeepAlive
I n this Article
Sets the KeepAlive attached property of the specified element.
public static void SetKeepAlive (System.Windows.DependencyObject dependencyObject, bool keepAlive);
static member SetKeepAlive : System.Windows.DependencyObject * bool -> unit

Parameters
dependencyObject DependencyObject DependencyObject
The element on which to set the attached property value.
keepAlive Boolean Boolean
true to keep the journal entry in memory; otherwise, false .
See KeepAliveKeepAlive
Also
JournalEntry.SetName JournalEntry.SetName
I n this Article
Sets the Name attached property of the specified element.
public static void SetName (System.Windows.DependencyObject dependencyObject, string name);
static member SetName : System.Windows.DependencyObject * string -> unit

Parameters
dependencyObject DependencyObject DependencyObject
The element on which to set the attached property value.
name String String
The name to be assigned to the attached property.
See NamePropertyNameProperty
Also
JournalEntry.Source JournalEntry.Source
I n this Article
Gets or sets the URI of the content that was navigated to.
public Uri Source { get; set; }
member this.Source : Uri with get, set

Returns
Uri Uri
The URI of the content that was navigated to, or null if no URI is associated with the entry.
JournalEntryListConverter JournalEntryListConverter
Class
This type or member supports the Microsoft .NET infrastructure and is not intended to be used directly from your
code.

D eclaration
public sealed class JournalEntryListConverter : System.Windows.Data.IValueConverter
type JournalEntryListConverter = class
interface IValueConverter

I nheritance H ierarchy
Object Object

Constructors
JournalEntryListConverter()
JournalEntryListConverter()

This type or member supports the Microsoft .NET infrastructure and is not intended to be used directly from your
code.

Methods
Convert(Object, Type, Object, CultureInfo)
Convert(Object, Type, Object, CultureInfo)

This type or member supports the Windows Presentation Foundation (WPF ) infrastructure and is not intended to
be used directly from your code.

ConvertBack(Object, Type, Object, CultureInfo)


ConvertBack(Object, Type, Object, CultureInfo)

This type or member supports the Windows Presentation Foundation (WPF ) infrastructure and is not intended to
be used directly from your code.
JournalEntryListConverter.Convert JournalEntryList
Converter.Convert
I n this Article
This type or member supports the Windows Presentation Foundation (WPF ) infrastructure and is not intended to be
used directly from your code.
public object Convert (object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture);
abstract member Convert : obj * Type * obj * System.Globalization.CultureInfo -> obj
override this.Convert : obj * Type * obj * System.Globalization.CultureInfo -> obj

Parameters
value Object Object
The value produced by the binding source.
targetType Type Type
The type of the binding target property.
parameter Object Object
The converter parameter to use.
culture CultureInfo CultureInfo
The culture to use in the converter.
Returns
Object Object
A converted value.
JournalEntryListConverter.ConvertBack JournalEntryList
Converter.ConvertBack
I n this Article
This type or member supports the Windows Presentation Foundation (WPF ) infrastructure and is not intended to be
used directly from your code.
public object ConvertBack (object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture);
abstract member ConvertBack : obj * Type * obj * System.Globalization.CultureInfo -> obj
override this.ConvertBack : obj * Type * obj * System.Globalization.CultureInfo -> obj

Parameters
value Object Object
The value produced by the binding target.
targetType Type Type
The type of the binding source property.
parameter Object Object
The converter parameter to use.
culture CultureInfo CultureInfo
The culture to use in the converter.
Returns
Object Object
A converted value.
JournalEntryListConverter
I n this Article
This type or member supports the Microsoft .NET infrastructure and is not intended to be used directly from your
code.

public JournalEntryListConverter ();


JournalEntryPosition JournalEntryPosition Enum
Specifies the position in navigation history of a piece of content with respect to current content. JournalEntryPosition is
used by JournalEntryUnifiedViewConverter.

D eclaration
public enum JournalEntryPosition
type JournalEntryPosition =

I nheritance H ierarchy
Object Object
ValueType ValueType
Enum Enum

Fields
Back Back Content is in back navigation history relative to current content.

Current Current Content is the current content.

Forward Forward Content is in forward navigation history with respect to current content.
JournalEntryUnifiedViewConverter JournalEntryUnified
ViewConverter Class
JournalEntryUnifiedViewConverter merges navigation back history and navigation forward history (as exposed by
Frame or NavigationWindow ) into a single, Windows Internet Explorer 7-style navigation menu.

D eclaration
public sealed class JournalEntryUnifiedViewConverter : System.Windows.Data.IMultiValueConverter
type JournalEntryUnifiedViewConverter = class
interface IMultiValueConverter

I nheritance H ierarchy
Object Object

Remarks
Both Frame and NavigationWindow display navigation chrome that supports history navigation using the following
mechanisms:
A button for navigating back one piece of content at a time.
A button for navigating forward one piece of content at a time.
An Windows Internet Explorer 7-style drop-down list that shows:
A combined list of up to nine items in back navigation history and up to nine items in forward navigation history.
The position of the current piece of content with respect to both back and forward navigation history.
The navigation history is stored by both NavigationWindow and Frame in the following properties:
Back Navigation History: Frame.BackStack, NavigationWindow.BackStack.
Forward Navigation History: Frame.ForwardStack, NavigationWindow.ForwardStack.
To create the Windows Internet Explorer 7-style drop-down list, NavigationWindow and Frame use
JournalEntryUnifiedViewConverter to merge their individual back navigation history and forward navigation history
into a single list of navigation history entries. The resulting list contains up to nine entries from back navigation history
and up to nine entries from forward navigation history, plus an entry for the current content.
If you create custom navigation UI, and need to provide an Windows Internet Explorer 7-style drop-down list, you can
use JournalEntryUnifiedViewConverter to similar effect.
X A ML Attribute Usage
This class is not typically used in XAML.

Constructors
JournalEntryUnifiedViewConverter()
JournalEntryUnifiedViewConverter()

Initializes a new instance of the JournalEntryUnifiedViewConverter class.


Fields
JournalEntryPositionProperty
JournalEntryPositionProperty

Identifies the JournalEntryPosition attached property.

JournalEntryPosition
JournalEntryPosition

Gets or sets a value that specifies whether an entry is in back navigation history, forward navigation history, or is
the current content of a navigator.

Methods
Convert(Object[], Type, Object, CultureInfo)
Convert(Object[], Type, Object, CultureInfo)

Merges two navigation history stacks.

ConvertBack(Object, Type[], Object, CultureInfo)


ConvertBack(Object, Type[], Object, CultureInfo)

Not implemented.

GetJournalEntryPosition(DependencyObject)
GetJournalEntryPosition(DependencyObject)

Gets the JournalEntryPosition attached property for the specified element.

SetJournalEntryPosition(DependencyObject, JournalEntryPosition)
SetJournalEntryPosition(DependencyObject, JournalEntryPosition)

Sets the JournalEntryPositionProperty attached property of the specified element.

See Also
JournalEntryPosition JournalEntryPosition
JournalEntryUnifiedViewConverter.Convert JournalEntry
UnifiedViewConverter.Convert
I n this Article
Merges two navigation history stacks.

public object Convert (object[] values, Type targetType, object parameter,


System.Globalization.CultureInfo culture);
abstract member Convert : obj[] * Type * obj * System.Globalization.CultureInfo -> obj
override this.Convert : obj[] * Type * obj * System.Globalization.CultureInfo -> obj

Parameters
values Object[]
An array of two navigation stacks.
targetType Type Type
This parameter is not used.
parameter Object Object
This parameter is not used.
culture CultureInfo CultureInfo
This parameter is not used.
Returns
Object Object
An IEnumerable that can be used to enumerate the merged list of navigation history stacks if neither passed navigation
stack is null . null , otherwise.

Remarks
For Frame, the navigation stacks are available from the following properties:
BackStack
ForwardStack
For NavigationWindow, the navigation stacks are available from the following properties:
BackStack
ForwardStack
The two passed navigation stacks are combined into a single navigation stack that contains up to nine items from each
navigation stack plus the current item.
X A ML Attribute Usage
Members of this class are either not typically used in XAML, or cannot be used in XAML.
JournalEntryUnifiedViewConverter.ConvertBack Journal
EntryUnifiedViewConverter.ConvertBack
I n this Article
Not implemented.

public object[] ConvertBack (object value, Type[] targetTypes, object parameter,


System.Globalization.CultureInfo culture);
abstract member ConvertBack : obj * Type[] * obj * System.Globalization.CultureInfo -> obj[]
override this.ConvertBack : obj * Type[] * obj * System.Globalization.CultureInfo -> obj[]

Parameters
value Object Object
This parameter is not used.
targetTypes Type[]
This parameter is not used.
parameter Object Object
This parameter is not used.
culture CultureInfo CultureInfo
This parameter is not used.
Returns
Object[]
Always returns DoNothing.

Remarks
X A ML Attribute Usage
Members of this class are either not typically used in XAML, or cannot be used in XAML.
JournalEntryUnifiedViewConverter.GetJournalEntry
Position JournalEntryUnifiedViewConverter.GetJournal
EntryPosition
I n this Article
Gets the JournalEntryPosition attached property for the specified element.
public static System.Windows.Navigation.JournalEntryPosition GetJournalEntryPosition
(System.Windows.DependencyObject element);
static member GetJournalEntryPosition : System.Windows.DependencyObject ->
System.Windows.Navigation.JournalEntryPosition

Parameters
element DependencyObject DependencyObject
The element from which to get the attached property value.
Returns
JournalEntryPosition JournalEntryPosition
The value of the JournalEntryPosition attached property of the journal entry for the specified element.
JournalEntryUnifiedViewConverter.JournalEntryPosition
Property JournalEntryUnifiedViewConverter.JournalEntry
PositionProperty
I n this Article
Identifies the JournalEntryPosition attached property.
public static readonly System.Windows.DependencyProperty JournalEntryPositionProperty;
staticval mutable JournalEntryPositionProperty : System.Windows.DependencyProperty

Returns
DependencyProperty DependencyProperty
JournalEntryUnifiedViewConverter
I n this Article
Initializes a new instance of the JournalEntryUnifiedViewConverter class.
public JournalEntryUnifiedViewConverter ();
JournalEntryUnifiedViewConverter.SetJournalEntry
Position JournalEntryUnifiedViewConverter.SetJournal
EntryPosition
I n this Article
Sets the JournalEntryPositionProperty attached property of the specified element.
public static void SetJournalEntryPosition (System.Windows.DependencyObject element,
System.Windows.Navigation.JournalEntryPosition position);
static member SetJournalEntryPosition : System.Windows.DependencyObject *
System.Windows.Navigation.JournalEntryPosition -> unit

Parameters
element DependencyObject DependencyObject
The element on which to set the attached property value.
position JournalEntryPosition JournalEntryPosition
Position of the JournalEntryPosition object.

Remarks
X A ML Attribute Usage
Members of this class are either not typically used in XAML, or cannot be used in XAML.
JournalOwnership JournalOwnership Enum
Specifies whether a Frame uses its own journal. JournalOwnership is used by the JournalOwnership property.

D eclaration
[System.Serializable]
public enum JournalOwnership
type JournalOwnership =

I nheritance H ierarchy
Object Object
ValueType ValueType
Enum Enum

Remarks
When JournalOwnership is Automatic, the following behavior applies:
The hosted Frame behaves as though UsesParentJournal was set if it is hosted by either a Frame or a
NavigationWindow.
The hosted Frame behaves as though OwnsJournal was set if:
It is not directly hosted by either a Frame or NavigationWindow.
It is hosted by at least one Frame, where each containing Frame has its JournalOwnership property is set to
UsesParentJournal.
Note

once a Frame creates its own journal, switching to Automatic has no effect.

Fields
Automatic Automatic Whether or not this Frame will create and use its own journal depends on its parent.

OwnsJournal The Frame maintains its own journal.


OwnsJournal

UsesParentJournal The Frame uses the journal of the next available navigation host up the content tree, if available.
UsesParentJournal Otherwise, navigation history is not maintained for the Frame.
LoadCompletedEventHandler LoadCompletedEvent
Handler Delegate
Represents the method that will handle LoadCompleted events.

D eclaration
public delegate void LoadCompletedEventHandler(object sender, NavigationEventArgs e);
type LoadCompletedEventHandler = delegate of obj * NavigationEventArgs -> unit

I nheritance H ierarchy
Object Object
Delegate Delegate

Remarks
This event handler is used for the following events:
NavigationService.LoadCompleted
NavigationWindow.LoadCompleted
Frame.LoadCompleted
Application.LoadCompleted
NavigatedEventHandler NavigatedEventHandler
Delegate
Represents the method that will handle Navigated events.

D eclaration
public delegate void NavigatedEventHandler(object sender, NavigationEventArgs e);
type NavigatedEventHandler = delegate of obj * NavigationEventArgs -> unit

I nheritance H ierarchy
Object Object
Delegate Delegate

Remarks
This event handler is used for the following events:
NavigationService.Navigated
NavigationWindow.Navigated
Frame.Navigated
Application.Navigated
NavigatingCancelEventArgs NavigatingCancelEventArgs
Class
Provides data for the Navigating event.

D eclaration
public class NavigatingCancelEventArgs : System.ComponentModel.CancelEventArgs
type NavigatingCancelEventArgs = class
inherit CancelEventArgs

I nheritance H ierarchy
Object Object
EventArgs EventArgs
CancelEventArgs CancelEventArgs

Remarks
These event arguments contain information about the navigation that was requested, and are passed to handlers of the
Navigating event, which is implemented by the following:
NavigationService.Navigating
NavigationWindow.Navigating
Frame.Navigating
Application.Navigating
NavigatingCancelEventArgs encapsulates the following details of the navigation request:
Navigation Initiation: NavigationMode, Navigator, IsNavigationInitiator.
Navigation Content: Uri, Content.
Navigation Request: WebRequest.
Navigation State: ExtraData, ContentStateToSave, TargetContentState.
This information allows you to both evaluate the nature of the navigation request, and view and update specified
request details before navigation occurs.
Based on the navigation request information provided by NavigatingCancelEventArgs, or based on application-specific
state or code, you can completely prevent navigation by setting the Cancel property to true (by default, Cancel is
false ).

Properties
Content
Content

Gets a reference to the content object that is being navigated to.

ContentStateToSave
ContentStateToSave

Gets or sets the CustomContentState object that is associated with the back navigation history entry for the page
being navigated from.

ExtraData
ExtraData

Gets the optional data Object that was passed when navigation started.

IsNavigationInitiator
IsNavigationInitiator

Indicates whether the navigator (NavigationWindow, Frame) that is specified by Navigator is servicing this
navigation, or whether a parent navigator is doing so.

NavigationMode
NavigationMode

Gets a NavigationMode value that indicates the type of navigation that is occurring.

Navigator
Navigator

The navigator that raised this event.

TargetContentState
TargetContentState

Gets the CustomContentState object that is to be applied to the content being navigated to.

Uri
Uri

Gets the uniform resource identifier (URI) for the content being navigated to.

WebRequest
WebRequest

Gets the WebRequest object that is used to request the specified content.
NavigatingCancelEventArgs.Content NavigatingCancel
EventArgs.Content
I n this Article
Gets a reference to the content object that is being navigated to.

public object Content { get; }


member this.Content : obj

Returns
Object Object
A Object reference to the content object that is being navigated to; otherwise, null .

Remarks
You can navigate to content using either a uniform resource identifier (URI) or an object. When navigating to an object,
which occurs when calling NavigationService.Navigate and NavigationService.Navigate, Content contains a reference
to the content object that is being navigated to. Additionally, the Uri property will be null .
NavigatingCancelEventArgs.ContentStateToSave
NavigatingCancelEventArgs.ContentStateToSave
I n this Article
Gets or sets the CustomContentState object that is associated with the back navigation history entry for the page being
navigated from.
public System.Windows.Navigation.CustomContentState ContentStateToSave { get; set; }
member this.ContentStateToSave : System.Windows.Navigation.CustomContentState with get, set

Returns
CustomContentState CustomContentState
The CustomContentState object that is associated with the back navigation history entry for the page being navigated
from.

Remarks
Navigating event is raised when navigating from one piece of content to another. The content that is being navigated
from is added to back navigation history. You can set ContentStateToSave with a custom CustomContentState object to
associate state information with content in navigation history.
NavigatingCancelEventArgs.ExtraData NavigatingCancel
EventArgs.ExtraData
I n this Article
Gets the optional data Object that was passed when navigation started.

public object ExtraData { get; }


member this.ExtraData : obj

Returns
Object Object
The optional data Object that was passed when navigation started.

Remarks
ExtraData can be used to pass context-specific data that is specific to a particular navigation. ExtraData contains a
reference to the object that is passed as the second argument when calling either NavigationService.Navigate or
NavigationService.Navigate. Otherwise, it is null .
NavigatingCancelEventArgs.IsNavigationInitiator
NavigatingCancelEventArgs.IsNavigationInitiator
I n this Article
Indicates whether the navigator (NavigationWindow, Frame) that is specified by Navigator is servicing this navigation,
or whether a parent navigator is doing so.
public bool IsNavigationInitiator { get; }
member this.IsNavigationInitiator : bool

Returns
Boolean Boolean
A Boolean value that is true if the navigator that is specified by Navigator is servicing this navigation. Otherwise,
false is returned, such as during a nested Frame navigation.
NavigatingCancelEventArgs.NavigationMode Navigating
CancelEventArgs.NavigationMode
I n this Article
Gets a NavigationMode value that indicates the type of navigation that is occurring.

public System.Windows.Navigation.NavigationMode NavigationMode { get; }


member this.NavigationMode : System.Windows.Navigation.NavigationMode

Returns
NavigationMode NavigationMode
A NavigationMode value that indicates the type of navigation that is occurring.

Remarks
The types of navigation that can occur are:
Navigating to new content (New ).
Navigating to the previous item in back navigation history ( Back).
Navigating to the next item in forward navigation history ( Forward).
Refreshing existing content (Refresh).
NavigatingCancelEventArgs.Navigator NavigatingCancel
EventArgs.Navigator
I n this Article
The navigator that raised this event.

public object Navigator { get; }


member this.Navigator : obj

Returns
Object Object
An Object that is the navigator that raised this event

Remarks
While Navigator stores a reference to the navigator that raised this event, the navigator may not have actually initiated
the navigation. To determine whether this navigator did initiate the current navigation, inspect the IsNavigationInitiator
property.
NavigatingCancelEventArgs.TargetContentState
NavigatingCancelEventArgs.TargetContentState
I n this Article
Gets the CustomContentState object that is to be applied to the content being navigated to.

public System.Windows.Navigation.CustomContentState TargetContentState { get; }


member this.TargetContentState : System.Windows.Navigation.CustomContentState

Returns
CustomContentState CustomContentState
The CustomContentState object that is to be applied to the content being navigated to.

Remarks
TargetContentState will contain a CustomContentState object if navigating to content in back or forward navigation
history that has a CustomContentState object associated with it.
NavigatingCancelEventArgs.Uri NavigatingCancelEvent
Args.Uri
I n this Article
Gets the uniform resource identifier (URI) for the content being navigated to.

public Uri Uri { get; }


member this.Uri : Uri

Returns
Uri Uri
The Uri for the content being navigated to. If navigating to an object, Uri is null .

Remarks
You can navigate to content using either an uniform resource identifier (URI) or an object. When navigating to an URI,
which occurs when calling NavigationService.Navigate and NavigationService.Navigate, Uri contains the URI of the
content being navigated to. Additionally, the Content property will be null .
NavigatingCancelEventArgs.WebRequest Navigating
CancelEventArgs.WebRequest
I n this Article
Gets the WebRequest object that is used to request the specified content.

public System.Net.WebRequest WebRequest { get; }


member this.WebRequest : System.Net.WebRequest

Returns
WebRequest WebRequest
Gets the WebRequest object that is used to request the specified content.

Remarks
System.Net.WebRequest is an abstract base class that encapsulates a Web request, and is protocol agnostic. For each
common protocol, the .NET Framework includes a class that derives from System.Net.WebRequest and extends it with
protocol specific state and behavior, including:
PackWebRequest: URIs that use the pack:// scheme to request application data files (see WPF Application Resource,
Content, and Data Files).
HttpWebRequest: URIs that use the http:// scheme to request files from Web servers.
FtpWebRequest: URIs that use the ftp:// scheme to request files from FTP servers.
FileWebRequest: URIs that use the file:// scheme to request local files.
You can both view and modify WebRequest details.
WebRequest is null when navigation occurs by:

Using the WebBrowser control.


Calling Navigate
Setting NavigationService.Content.
Navigating through HTML content in a Frame.
NavigatingCancelEventHandler NavigatingCancelEvent
Handler Delegate
Represents the method that will handle Navigating events.

D eclaration
public delegate void NavigatingCancelEventHandler(object sender, NavigatingCancelEventArgs e);
type NavigatingCancelEventHandler = delegate of obj * NavigatingCancelEventArgs -> unit

I nheritance H ierarchy
Object Object
Delegate Delegate

Remarks
This event handler is used for the following events:
NavigationService.Navigating
NavigationWindow.Navigating
Frame.Navigating
Application.Navigating
NavigationEventArgs NavigationEventArgs Class
Provides data for non-cancelable navigation events, including LoadCompleted, Navigated, and NavigationStopped.

D eclaration
public class NavigationEventArgs : EventArgs
type NavigationEventArgs = class
inherit EventArgs

I nheritance H ierarchy
Object Object
EventArgs EventArgs

Properties
Content
Content

Gets the root node of the target page's content.

ExtraData
ExtraData

Gets an optional user-defined data object.

IsNavigationInitiator
IsNavigationInitiator

Gets a value that indicates whether the current navigator initiated the navigation.

Navigator
Navigator

Gets the navigator that raised the event

Uri
Uri

Gets the uniform resource identifier (URI) of the target page.

WebResponse
WebResponse

Gets the Web response to allow access to HTTP headers and other properties.
NavigationEventArgs.Content NavigationEventArgs.
Content
I n this Article
Gets the root node of the target page's content.

public object Content { get; }


member this.Content : obj

Returns
Object Object
The root element of the target page's content.
NavigationEventArgs.ExtraData NavigationEventArgs.
ExtraData
I n this Article
Gets an optional user-defined data object.

public object ExtraData { get; }


member this.ExtraData : obj

Returns
Object Object
The data object.

Remarks
When you call Navigate to navigate to a new page, you have the option of passing the method a user-defined data
object. That object is then assigned to this property so that you have easy access to the data when you handle the
Navigate event.
NavigationEventArgs.IsNavigationInitiator Navigation
EventArgs.IsNavigationInitiator
I n this Article
Gets a value that indicates whether the current navigator initiated the navigation.

public bool IsNavigationInitiator { get; }


member this.IsNavigationInitiator : bool

Returns
Boolean Boolean
true if the navigation was initiated inside the current frame; false if the parent navigator is also navigating.

Remarks
This property indicates whether the current navigator is initiating the navigation or whether a parent navigator is being
navigated. For example, the current navigator might be a frame inside a page that is being navigated to inside a parent
navigator. You can use this property to determine whether to spin the globe on a Navigating event or to stop spinning
the globe on a LoadCompleted event. If this property is false , the navigator's parent navigator is also navigating and
the globe is already spinning. If this property is true , the navigation was initiated inside the current frame and you
should spin the globe (or stop spinning the globe, depending on which event is being handled.)
NavigationEventArgs.Navigator NavigationEventArgs.
Navigator
I n this Article
Gets the navigator that raised the event

public object Navigator { get; }


member this.Navigator : obj

Returns
Object Object
The navigator that raised the event.
NavigationEventArgs.Uri NavigationEventArgs.Uri
I n this Article
Gets the uniform resource identifier (URI) of the target page.
public Uri Uri { get; }
member this.Uri : Uri

Returns
Uri Uri
The URI of the target page.
NavigationEventArgs.WebResponse NavigationEvent
Args.WebResponse
I n this Article
Gets the Web response to allow access to HTTP headers and other properties.

public System.Net.WebResponse WebResponse { get; }


member this.WebResponse : System.Net.WebResponse

Returns
WebResponse WebResponse
The Web response.
NavigationFailedEventArgs NavigationFailedEventArgs
Class
Provides data for the NavigationFailed event.

D eclaration
public class NavigationFailedEventArgs : EventArgs
type NavigationFailedEventArgs = class
inherit EventArgs

I nheritance H ierarchy
Object Object
EventArgs EventArgs

Remarks
These event arguments contain information about a navigation that failed, and are passed to handlers of the
NavigationFailed event, which is implemented by the following:
NavigationService.NavigationFailed
NavigationWindow.NavigationFailed
Frame.NavigationFailed
Application.NavigationFailed
NavigationFailedEventArgs encapsulates the following details of the failed navigation request:
Navigation Initiation: Navigator.
Navigation Exception: Exception, Handled.
Navigation Content: Uri.
Navigation Details: WebRequest, WebResponse.
Navigation State: ExtraData.

Properties
Exception
Exception

Gets the Exception that was raised as the result of a failed navigation.

ExtraData
ExtraData

Gets the optional data Object that was passed when navigation commenced.
Handled
Handled

Gets or sets whether the failed navigation exception has been handled.

Navigator
Navigator

The navigator that raised this event.

Uri
Uri

Gets the uniform resource identifier (URI) for the content that could not be navigated to.

WebRequest
WebRequest

Gets the web request that was used to request the specified content.

WebResponse
WebResponse

Gets the web response that was returned after attempting to download the requested the specified content.
NavigationFailedEventArgs.Exception NavigationFailed
EventArgs.Exception
I n this Article
Gets the Exception that was raised as the result of a failed navigation.

public Exception Exception { get; }


member this.Exception : Exception

Returns
Exception Exception
The Exception that was raised as the result of a failed navigation.

Remarks
Exception will be either a WebException or an IOException
NavigationFailedEventArgs.ExtraData NavigationFailed
EventArgs.ExtraData
I n this Article
Gets the optional data Object that was passed when navigation commenced.

public object ExtraData { get; }


member this.ExtraData : obj

Returns
Object Object
The optional data Object that was passed when navigation commenced.

Remarks
ExtraData can be used to pass context-specific data that is specific to a particular navigation. ExtraData contains a
reference to the object that is passed as the second argument when calling either Navigate or Navigate. Otherwise, it is
null .
NavigationFailedEventArgs.Handled NavigationFailed
EventArgs.Handled
I n this Article
Gets or sets whether the failed navigation exception has been handled.

public bool Handled { get; set; }


member this.Handled : bool with get, set

Returns
Boolean Boolean
true if the exception is handled; otherwise, false (default).

Remarks
When you handle NavigationFailed to process an exception that is thrown as a result of a failed navigation, and you
don't want WPF to continue processing the exception, you should set the Handled property to true .
NavigationFailedEventArgs.Navigator NavigationFailed
EventArgs.Navigator
I n this Article
The navigator that raised this event.

public object Navigator { get; }


member this.Navigator : obj

Returns
Object Object
An Object that is the navigator that raised this event
NavigationFailedEventArgs.Uri NavigationFailedEvent
Args.Uri
I n this Article
Gets the uniform resource identifier (URI) for the content that could not be navigated to.

public Uri Uri { get; }


member this.Uri : Uri

Returns
Uri Uri
The Uri for the content that could not be navigated to.
NavigationFailedEventArgs.WebRequest Navigation
FailedEventArgs.WebRequest
I n this Article
Gets the web request that was used to request the specified content.

public System.Net.WebRequest WebRequest { get; }


member this.WebRequest : System.Net.WebRequest

Returns
WebRequest WebRequest
Gets the WebRequest object that was used to request the specified content. If navigating to an object, WebRequest is
null .

Remarks
System.Net.WebRequest is an abstract base class that encapsulates a web request, and is protocol agnostic. For each
common protocol, the .NET Framework includes a class that derives from System.Net.WebRequest and extends it with
protocol-specific state and behavior, including:
PackWebRequest: URIs that use the pack:// scheme to request application data files (see WPF Application Resource,
Content, and Data Files).
HttpWebRequest: URIs that use the http:// scheme to request files from Web servers.
FtpWebRequest: URIs that use the ftp:// scheme to request files from FTP servers.
FileWebRequest: URIs that use the file:// scheme to request local files.
NavigationFailedEventArgs.WebResponse Navigation
FailedEventArgs.WebResponse
I n this Article
Gets the web response that was returned after attempting to download the requested the specified content.

public System.Net.WebResponse WebResponse { get; }


member this.WebResponse : System.Net.WebResponse

Returns
WebResponse WebResponse
The WebResponse that was returned after attempting to download the requested the specified content. If the
navigation failed, WebResponse is null .

Remarks
System.Net.WebResponse is an abstract base class that encapsulates a web response, and is protocol agnostic. For
each common protocol, the .NET Framework includes a class that derives from System.Net.WebResponse and extends
it with protocol-specific state, including:
PackWebResponse: URIs that use the pack:// scheme to request application data files (see WPF Application
Resource, Content, and Data Files).
HttpWebResponse: URIs that use the http:// scheme to request files from Web servers.
FtpWebResponse: URIs that use the ftp:// scheme to request files from FTP servers.
FileWebResponse: URIs that use the file:// scheme to request local files.
NavigationFailedEventHandler NavigationFailedEvent
Handler Delegate
Represents the method that will handle NavigationFailed events.

D eclaration
public delegate void NavigationFailedEventHandler(object sender, NavigationFailedEventArgs e);
type NavigationFailedEventHandler = delegate of obj * NavigationFailedEventArgs -> unit

I nheritance H ierarchy
Object Object
Delegate Delegate

Remarks
This event handler is used for the following events:
NavigationService.NavigationFailed
NavigationWindow.NavigationFailed
Frame.NavigationFailed
Application.NavigationFailed
NavigationMode NavigationMode Enum
Specifies the type of navigation that is taking place NavigationMode is used by the NavigationMode property.

D eclaration
public enum NavigationMode
type NavigationMode =

I nheritance H ierarchy
Object Object
ValueType ValueType
Enum Enum

Fields
Back Back Navigating back to the most recent content in back navigation history. This occurs when the GoBack
method is called.

Forward Navigating to the most recent content on forward navigation history. This occurs when the GoForward
Forward method is called.

New New Navigating to new content. This occurs when the Navigate method is called, or when Source property is
set.

Refresh Reloading the current content. This occurs when the Refresh method is called.
Refresh
NavigationProgressEventArgs NavigationProgressEvent
Args Class
Provides data for the NavigationProgress and NavigationProgress events.

D eclaration
public class NavigationProgressEventArgs : EventArgs
type NavigationProgressEventArgs = class
inherit EventArgs

I nheritance H ierarchy
Object Object
EventArgs EventArgs

Properties
BytesRead
BytesRead

Gets the number of bytes that have been read.

MaxBytes
MaxBytes

Gets the maximum number of bytes.

Navigator
Navigator

Gets the navigator that raised the event

Uri
Uri

Gets the uniform resource identifier (URI) of the target page.


NavigationProgressEventArgs.BytesRead Navigation
ProgressEventArgs.BytesRead
I n this Article
Gets the number of bytes that have been read.

public long BytesRead { get; }


member this.BytesRead : int64

Returns
Int64 Int64
The number of bytes that have been read.
NavigationProgressEventArgs.MaxBytes Navigation
ProgressEventArgs.MaxBytes
I n this Article
Gets the maximum number of bytes.

public long MaxBytes { get; }


member this.MaxBytes : int64

Returns
Int64 Int64
The maximum number of bytes.
NavigationProgressEventArgs.Navigator Navigation
ProgressEventArgs.Navigator
I n this Article
Gets the navigator that raised the event

public object Navigator { get; }


member this.Navigator : obj

Returns
Object Object
The navigator that raised the event
NavigationProgressEventArgs.Uri NavigationProgress
EventArgs.Uri
I n this Article
Gets the uniform resource identifier (URI) of the target page.

public Uri Uri { get; }


member this.Uri : Uri

Returns
Uri Uri
The URI of the target page.
NavigationProgressEventHandler NavigationProgress
EventHandler Delegate
Represents the method that will handle NavigationProgress events.

D eclaration
public delegate void NavigationProgressEventHandler(object sender, NavigationProgressEventArgs
e);
type NavigationProgressEventHandler = delegate of obj * NavigationProgressEventArgs -> unit

I nheritance H ierarchy
Object Object
Delegate Delegate

Remarks
This event handler is used for the following events:
NavigationService.NavigationProgress
NavigationWindow.NavigationProgress
Frame.NavigationProgress
Application.NavigationProgress
NavigationService NavigationService Class
Contains methods, properties, and events to support navigation.

D eclaration
public sealed class NavigationService
type NavigationService = class

I nheritance H ierarchy
Object Object

Remarks
NavigationService encapsulates the ability to download content within the context of a browser-style navigation.
Content can be any type of .NET Framework object and HTML files. In general, however, pages are the preferred as the
way to package content for navigation (see Page).
Content can be navigated to by providing an instance of an object and calling an overload of the Navigate method that
accepts an object:
NavigationService.Navigate(Object)
NavigationService.Navigate(Object, Object)
Alternatively, content can be navigated to by passing a relative or absolute URI to one of the Navigate method
overloads that accepts a URI:
NavigationService.Navigate(Uri)
NavigationService.Navigate(Uri, Object)
NavigationService.Navigate(Uri, Object, Boolean)
When content is navigated to by URI, NavigationService will return an object that contains the content.
The lifetime of a navigation can be tracked through the following events:
Navigating
Navigated
NavigationProgress
NavigationFailed
NavigationStopped
LoadCompleted
FragmentNavigation.
Not all events are raised each time that a navigation occurs; the set of events that are raised is determined by the type
of navigation that occurs (content or content fragment) and how the navigation completes (canceled, stopped, or
failed).
The following figure illustrates the sequence in which these events are raised:
During or after a navigation, NavigationService provides information about the content that is being navigated to,
including the URI of the content being navigated to (Source), the URI of the current content (CurrentSource), and an
object that contains the content that was navigated to (Content).
When content is navigated to, NavigationService records the navigation as an entry in navigation history. An entry is
added to back navigation history when either a new navigation occurs, by calling the Navigate method, or by
navigating to an entry in forward navigation history, by calling GoForward. An entry is added to forward navigation
history by navigating to an entry in back navigation history, by calling GoBack. CanGoBack and CanGoForward report
whether there are entries in back and forward navigation history, respectively. Also, the most recent entry in back
navigation history can be removed by calling RemoveBackEntry.
By default, NavigationService does not store an instance of a content object in navigation history. Instead,
NavigationService creates a new instance of the content object each time it is navigated to by using navigation history.
This behavior is designed to avoid excessive memory consumption when large numbers and large pieces of content
are being navigated to. Consequently, the state of the content is not remembered from one navigation to the next.
However, WPF provides several techniques by which you can store a piece of state for a piece of content in navigation
history.
Using AddBackEntry, you can also remember multiple sets of state for a single page instance.
NavigationService is a sealed class and therefore cannot be instantiated; instead, NavigationService is used by
navigators to enable navigation. In WPF, there are two navigators: NavigationWindow and Frame.
Visually, XBAPs use Internet Explorer 7 as a navigator, to provide an integrated user experience. Physically, however,
XBAPs actually use NavigationWindow as the navigator; the MainWindow property of an XBAP running in Internet
Explorer 7 will return a reference to the NavigationWindow, and the navigation history that is managed by the
NavigationWindow is integrated with the navigation history that is managed by Internet Explorer 7 in the following
ways:
When content is navigated to by calling Navigate, GoBack, and GoForward from within an XBAP the relevant
navigation history entries are also added to Internet Explorer 7 navigation history.
When entries in the Internet Explorer 7 navigation UI are selected, Internet Explorer 7 causes NavigationService to
navigate back or forwards to the content that is associated with those entries.
Note

A Frame can provide its own navigation history, or use the navigation history of the navigator that hosts it. If Frame
provides its own navigation history, it can display its own navigation UI to navigate through the entries in navigation
history; those entries are not added to the navigation history of the host navigator (NavigationWindow, Frame,
Internet Explorer) and, consequently, cannot be navigated to from the navigation UI of each (see JournalOwnership).
Properties
CanGoBack
CanGoBack

Gets a value that indicates whether there is at least one entry in back navigation history.

CanGoForward
CanGoForward

Gets a value that indicates whether there is at least one entry in forward navigation history.

Content
Content

Gets or sets a reference to the object that contains the current content.

CurrentSource
CurrentSource

Gets the URI of the content that was last navigated to.

Source
Source

Gets or sets the URI of the current content, or the URI of new content that is currently being navigated to.

Methods
AddBackEntry(CustomContentState)
AddBackEntry(CustomContentState)

Adds an entry to back navigation history that contains a CustomContentState object.

GetNavigationService(DependencyObject)
GetNavigationService(DependencyObject)

Gets a reference to the NavigationService for the navigator whose content contains the specified
DependencyObject.

GoBack()
GoBack()

Navigates to the most recent entry in back navigation history, if there is one.
GoForward()
GoForward()

Navigate to the most recent entry in forward navigation history, if there is one.

Navigate(Uri, Object, Boolean)


Navigate(Uri, Object, Boolean)

Navigate asynchronously to source content located at a URI, pass an object containing navigation state for
processing during navigation, and sandbox the content.

Navigate(Uri, Object)
Navigate(Uri, Object)

Navigate asynchronously to source content located at a URI, and pass an object that contains data to be used for
processing during navigation.

Navigate(Uri)
Navigate(Uri)

Navigate asynchronously to content that is specified by a URI.

Navigate(Object)
Navigate(Object)

Navigate asynchronously to content that is contained by an object.

Navigate(Object, Object)
Navigate(Object, Object)

Navigate asynchronously to content that is contained by an object, and pass an object that contains data to be
used for processing during navigation.

Refresh()
Refresh()

Reloads the current content.

RemoveBackEntry()
RemoveBackEntry()

Removes the most recent journal entry from back history.

StopLoading()
StopLoading()
Stops further downloading of content for the current navigation request.

Events
FragmentNavigation
FragmentNavigation

Occurs when navigation to a content fragment begins, which occurs immediately, if the desired fragment is in the
current content, or after the source XAML content has been loaded, if the desired fragment is in different content.

LoadCompleted
LoadCompleted

Occurs when content that was navigated to has been loaded, parsed, and has begun rendering.

Navigated
Navigated

Occurs when the content that is being navigated to has been found, and is available from the Content property,
although it may not have completed loading.

Navigating
Navigating

Occurs when a new navigation is requested.

NavigationFailed
NavigationFailed

Occurs when an error occurs while navigating to the requested content.

NavigationProgress
NavigationProgress

Occurs periodically during a download to provide navigation progress information.

NavigationStopped
NavigationStopped

Occurs when the StopLoading() method is called, or when a new navigation is requested while a current
navigation is in progress.
NavigationService.AddBackEntry NavigationService.Add
BackEntry
I n this Article
Adds an entry to back navigation history that contains a CustomContentState object.

public void AddBackEntry (System.Windows.Navigation.CustomContentState state);


member this.AddBackEntry : System.Windows.Navigation.CustomContentState -> unit

Parameters
state CustomContentState CustomContentState
A CustomContentState object that represents application-defined state that is associated with a specific piece of
content.
Exceptions
InvalidOperationException InvalidOperationException
state is null , and a CustomContentState object isn't returned from GetContentState().

Remarks
AddBackEntry, CustomContentState, and IProvideCustomContentState are used to help remember multiple sets of
state for the current content.
See RemoveBackEntry()RemoveBackEntry()
Also
NavigationService.CanGoBack NavigationService.CanGo
Back
I n this Article
Gets a value that indicates whether there is at least one entry in back navigation history.

public bool CanGoBack { get; }


member this.CanGoBack : bool

Returns
Boolean Boolean
true if there is at least one entry in back navigation history; otherwise, false .

Remarks
CanGoBack to determine whether there is at least one entry in back navigation history. This property should be
inspected before calling GoBack; if GoBack is called and there are no entries in back navigation history, an
InvalidOperationException is thrown.
Note

that if navigation history is shared by multiple navigators (NavigationWindow, Frame), the most recent entry in back
navigation history may not have been added by the NavigationService for the current navigator.
See CanGoForwardCanGoForward
Also GoForward()GoForward()
NavigationService.CanGoForward NavigationService.
CanGoForward
I n this Article
Gets a value that indicates whether there is at least one entry in forward navigation history.

public bool CanGoForward { get; }


member this.CanGoForward : bool

Returns
Boolean Boolean
true if there is at least one entry in forward navigation history; otherwise, false .

Remarks
CanGoForward to determine whether there is at least one entry in forward navigation history. This property should be
inspected before calling GoForward; if GoForward is called and there are no entries in forward navigation history, an
InvalidOperationException is thrown.
See CanGoBackCanGoBack
Also GoBack()GoBack()
NavigationService.Content NavigationService.Content
I n this Article
Gets or sets a reference to the object that contains the current content.
public object Content { get; set; }
member this.Content : obj with get, set

Returns
Object Object
An object that is a reference to the object that contains the current content.

Remarks
Content can be set in one of two ways:
Directly, by setting it to a reference to an object.
Indirectly, by calling Navigate, GoBack, or GoForward.
Setting NavigationService initiates a new navigation; since navigation is asynchronous, Content won't return a value if
it is inspected immediately after being set.
See NavigateNavigate
Also
NavigationService.CurrentSource NavigationService.
CurrentSource
I n this Article
Gets the URI of the content that was last navigated to.

public Uri CurrentSource { get; }


member this.CurrentSource : Uri

Returns
Uri Uri
A Uri for the content that was last navigated to, if navigated to by using a URI; otherwise, null .

Remarks
The value of the CurrentSource property is not changed until navigation to a different URI has completed successfully.
CurrentSource can be set with a fragment-only URI.
NavigationService.FragmentNavigation Navigation
Service.FragmentNavigation
I n this Article
Occurs when navigation to a content fragment begins, which occurs immediately, if the desired fragment is in the
current content, or after the source XAML content has been loaded, if the desired fragment is in different content.
public event System.Windows.Navigation.FragmentNavigationEventHandler FragmentNavigation;
member this.FragmentNavigation : System.Windows.Navigation.FragmentNavigationEventHandler

Examples
The following example shows how to handle FragmentNavigation to provide custom fragment navigation behavior. In
this case, the example opens an error XAML page if the fragment in the source XAML page is not found.
void NavigationService_FragmentNavigation(object sender, FragmentNavigationEventArgs e)
{
// Get content the ContentControl that contains the XAML page that was navigated to
object content = ((ContentControl)e.Navigator).Content;

// Find the fragment, which is the FrameworkElement with its Name attribute set
FrameworkElement fragmentElement = LogicalTreeHelper.FindLogicalNode((DependencyObject)content,
e.Fragment) as FrameworkElement;

// If fragment found, bring it into view, or open an error page


if (fragmentElement == null)
{
this.NavigationService.Navigate(new FragmentNotFoundPage());

// Don't let NavigationService handle this event, since we just did


e.Handled = true;
}
}

Remarks
By default, a content fragment is content that is contained by a named UIElement, which is a UIElement whose Name
attribute is set, eg:
<TextBlock Name="FragmentName">...</TextBlock>

You navigate to a XAML fragment by providing a URI with a suffix in the following format:
#FragmentName
The following shows an example of a URI that refers to a content fragment:
http://www.microsoft.com/targetpage.xaml#FragmentName

After the source page loads (after LoadCompleted event is raised), fragment navigation begins and the
NavigationService attempts to locate the XAML fragment. If the XAML fragment is found, NavigationService instructs
the content navigator (NavigationWindow, Frame) to show the fragment. If you need to change this behavior, you can
handle FragmentNavigation to provide your own fragment navigation behavior. FragmentNavigation is passed a
FragmentNavigationEventArgs parameter which exposes properties that are useful for this purpose, including:
The navigator that owns this navigation service ( NavigationWindow, Frame).
The fragment name.
You can handle FragmentNavigation to override the default WPF fragment implementation with your own custom
implementation. If you do so, you need to set Handled to true ; otherwise, the default WPF fragment processing
behavior is applied.
You should avoid directly initiating navigation from within a FragmentNavigation event handler. Since
FragmentNavigation is raised during an existing navigation, initiating a new navigation from a FragmentNavigation
event handler creates a nested navigation that can cause the ExecutionEngineException to be thrown. Instead, you can
indirectly initiate navigation by creating an asynchronous work item using the Dispatcher.
Note

When NavigationService raises FragmentNavigation, it also raises Application.FragmentNavigation event on the


Application object.
Im p o rt a nt

Fragment navigation is not supported for loose XAML pages (markup-only XAML files with Page as the root element)
in the following cases:
• When navigating to a fragment in a loose XAML page.
• When navigating from a loose XAML page to a fragment in another loose XAML page.
However, a loose XAML page can navigate to its own fragments.
See NavigatingNavigating
Also NavigatedNavigated
LoadCompletedLoadCompleted
NavigationProgressNavigationProgress
NavigationStoppedNavigationStopped
NavigationFailedNavigationFailed
NavigationService.GetNavigationService Navigation
Service.GetNavigationService
I n this Article
Gets a reference to the NavigationService for the navigator whose content contains the specified DependencyObject.

public static System.Windows.Navigation.NavigationService GetNavigationService


(System.Windows.DependencyObject dependencyObject);
static member GetNavigationService : System.Windows.DependencyObject ->
System.Windows.Navigation.NavigationService

Parameters
dependencyObject DependencyObject DependencyObject
The DependencyObject in content that is hosted by a navigator.
Returns
NavigationService NavigationService
A reference to the NavigationService for the navigator whose content contains the specified DependencyObject; can be
null in some cases.

Exceptions
ArgumentNullException ArgumentNullException
The dependencyObject parameter is null .

Examples
The following example shows how a UserControl can retrieve a navigation service by calling GetNavigationService.
void getNavigationServiceButton_Click(object sender, RoutedEventArgs e) {
// Retrieve first navigation service up the content tree
NavigationService svc = NavigationService.GetNavigationService(this.getNavigationServiceButton);
if (svc != null)
{
// Use navigation service

}
}

Remarks
A navigator has a NavigationService that handles content navigation. WPF has two navigators: NavigationWindow
and Frame. To process navigation requests and manage navigation lifetime, a navigator uses the WPF navigation
service, which is implemented as the NavigationService class. Content that is hosted by a navigator can get a reference
to the navigator's NavigationService by calling the GetNavigationService method.
GetNavigationService returns null when the dependencyObject :
Is a NavigationWindow.
Is a Frame that:
1. Is hosted by another navigator.
2. Has its JournalOwnership property set to UsesParentJournal.
Is not part of content that is hosted by a navigator.
WPF offers two shortcuts for acquiring a reference to the NavigationService:
The NavigationService that processed the navigation to a Page can be accessed from the Page itself by getting the
value of its Page.NavigationService property.
The NavigationService that is used by a Frame to process navigation can be accessed by getting the value of the
NavigationService property.
NavigationService.GoBack NavigationService.GoBack
I n this Article
Navigates to the most recent entry in back navigation history, if there is one.
public void GoBack ();
member this.GoBack : unit -> unit

Exceptions
InvalidOperationException InvalidOperationException
GoBack() is called when there are no entries in back navigation history.

Examples
The following example navigates to the most recent entry in back navigation history, if one exists.
void backButton_Click(object sender, RoutedEventArgs e)
{
if (this.NavigationService.CanGoBack)
{
this.NavigationService.GoBack();
}
}

Remarks
Before calling GoBack, the CanGoBack property can be inspected to determine whether there are entries in back
navigation history.
See CanGoForwardCanGoForward
Also GoForward()GoForward()
NavigationService.GoForward NavigationService.Go
Forward
I n this Article
Navigate to the most recent entry in forward navigation history, if there is one.

public void GoForward ();


member this.GoForward : unit -> unit

Exceptions
InvalidOperationException InvalidOperationException
GoForward() is called when there are no entries in forward navigation history.

Examples
The following example navigates to the most recent entry in forward navigation history, if one exists.
void forwardButton_Click(object sender, RoutedEventArgs e)
{
if (this.NavigationService.CanGoForward)
{
this.NavigationService.GoForward();
}
}

Remarks
Before calling GoForward, the CanGoForward property can be inspected to determine whether there are entries in
forward navigation history.
See CanGoBackCanGoBack
Also GoBack()GoBack()
NavigationService.LoadCompleted NavigationService.
LoadCompleted
I n this Article
Occurs when content that was navigated to has been loaded, parsed, and has begun rendering.

public event System.Windows.Navigation.LoadCompletedEventHandler LoadCompleted;


member this.LoadCompleted : System.Windows.Navigation.LoadCompletedEventHandler

Examples
The following example shows how to handle LoadCompleted.
void NavigationService_LoadCompleted(object sender, NavigationEventArgs e)
{
string msg = string.Format("{0} loaded.", e.Uri.OriginalString);
this.progressStatusBarItem.Content = msg;
}

Remarks
You handle LoadCompleted if you need to discover pertinent information regarding the navigation request upon load
completion. This information is available from the NavigationEventArgs object that is passed to the LoadCompleted
event handler, and includes:
The content and its URI.
The navigator (NavigationWindow, Frame).
Additional data, if the navigation was initiated by calling either Navigate or Navigate.
Response details (using a WebResponse object).
LoadCompleted is not raised when the source page could not be found or loaded, in which case NavigationFailed is
raised.
Note

When NavigationService raises LoadCompleted, it also raises Application.LoadCompleted event on the Application
object.
See NavigatingNavigating
Also NavigatedNavigated
NavigationProgressNavigationProgress
NavigationStoppedNavigationStopped
FragmentNavigationFragmentNavigation
NavigationFailedNavigationFailed
NavigationService.Navigate NavigationService.Navigate
I n this Article

Overloads
Navigate(Uri, Object, Boolean) Navigate(Uri, Object, Boolean)
Navigate asynchronously to source content located at a URI,
pass an object containing navigation state for processing
during navigation, and sandbox the content.

Navigate(Uri, Object) Navigate(Uri, Object)


Navigate asynchronously to source content located at a URI,
and pass an object that contains data to be used for
processing during navigation.

Navigate(Uri) Navigate(Uri)
Navigate asynchronously to content that is specified by a URI.

Navigate(Object) Navigate(Object)
Navigate asynchronously to content that is contained by an
object.

Navigate(Object, Object) Navigate(Object, Object)


Navigate asynchronously to content that is contained by an
object, and pass an object that contains data to be used for
processing during navigation.

Navigate(Uri, Object, Boolean) Navigate(Uri, Object, Boolean)


Navigate asynchronously to source content located at a URI, pass an object containing navigation state for processing
during navigation, and sandbox the content.

public bool Navigate (Uri source, object navigationState, bool sandboxExternalContent);


member this.Navigate : Uri * obj * bool -> bool

Parameters
source Uri Uri
A Uri object initialized with the URI for the desired content.
navigationState Object Object
An object that contains data to be used for processing during navigation.
sandboxExternalContent Boolean Boolean
Download content into a partial trust security sandbox (with the default Internet zone set of permissions, if true . The
default is false .
Returns
Boolean Boolean
true if a navigation is not canceled; otherwise, false .
Remarks
This method is only for standalone applications and Extensible Application Markup Language (XAML ) content.
This method exhibits the same behavior as NavigationService.Navigate, and extends it by ensuring that the content
that is being downloaded is placed into a partial trust security sandbox (with the default Internet zone set of
permissions - see WPF Partial Trust Security).
See Navigate(Uri)Navigate(Uri)
Also Navigate(Uri, Object)Navigate(Uri, Object)
Navigate(Object)Navigate(Object)
Navigate(Object, Object)Navigate(Object, Object)

Navigate(Uri, Object) Navigate(Uri, Object)


Navigate asynchronously to source content located at a URI, and pass an object that contains data to be used for
processing during navigation.
public bool Navigate (Uri source, object navigationState);
member this.Navigate : Uri * obj -> bool

Parameters
source Uri Uri
A Uri object initialized with the URI for the desired content.
navigationState Object Object
An object that contains data to be used for processing during navigation.
Returns
Boolean Boolean
true if a navigation is not canceled; otherwise, false .
Examples
The following example demonstrates navigating to a URI and passing navigation state.

void goButton_Click(object sender, RoutedEventArgs e)


{
this.NavigationService.Navigate(new Uri(this.addressTextBox.Text), DateTime.Now);
}
void NavigationService_LoadCompleted(object sender, NavigationEventArgs e)
{
DateTime requestDateTime = (DateTime)e.ExtraData;
string msg = string.Format("Request started {0}
Request completed {1}", requestDateTime, DateTime.Now);
MessageBox.Show(msg);
}

Remarks
Since navigations are asynchronous, it is possible for multiple navigations to be in progress at the same time. For
example, if there are two child frames on a single page, both frames could be navigating. In this case, the various
navigation events that are raised by NavigationService may be raised multiple times, one for each piece of content that
is being navigated to, and not necessarily in order that the navigations were requested. Consequently, if a particular
navigation request needs to process data that is specific to the individual request, it cannot use data that is available to
all navigation requests. Instead, you can use navigationState to pass data for navigation processing that is specific to
one navigation request.
The following event arguments provide access to navigation state:
ExtraData (passed to the Navigating event).
ExtraData (passed to the Navigated, NavigationStopped, LoadCompleted event handlers).
See Navigate(Uri)Navigate(Uri)
Also Navigate(Uri, Object, Boolean)Navigate(Uri, Object, Boolean)
Navigate(Object)Navigate(Object)
Navigate(Object, Object)Navigate(Object, Object)

Navigate(Uri) Navigate(Uri)
Navigate asynchronously to content that is specified by a URI.
public bool Navigate (Uri source);
member this.Navigate : Uri -> bool

Parameters
source Uri Uri
A Uri object initialized with the URI for the desired content.
Returns
Boolean Boolean
true if a navigation is not canceled; otherwise, false .
Examples
The following example shows how to navigate to a URI.
void goButton_Click(object sender, RoutedEventArgs e)
{
this.NavigationService.Navigate(new Uri(this.addressTextBox.Text));
}

Remarks
The value of source can be a Web URL or a valid pack URI (see Pack URIs in WPF ).
Navigate will navigate to the URI specified by source if the following conditions are true:

The Navigating event is not cancelled.


A web request (see Navigating) can be created.
If source is null , the existing content (Content) is cleared.
Note

When downloading Web content, you may receive a Web exception (for example, 404: File Not Found). You can handle
such exceptions from NavigationFailed.
You can use Navigate to navigate to a content fragment. If the content identified by the URI is the current content, it is
not downloaded again.
See Navigate(Uri, Object)Navigate(Uri, Object)
Also Navigate(Uri, Object, Boolean)Navigate(Uri, Object, Boolean)
Navigate(Object)Navigate(Object)
Navigate(Object, Object)Navigate(Object, Object)

Navigate(Object) Navigate(Object)
Navigate asynchronously to content that is contained by an object.

public bool Navigate (object root);


member this.Navigate : obj -> bool

Parameters
root Object Object
An object that contains the content to navigate to.
Returns
Boolean Boolean
true if a navigation is not canceled; otherwise, false .
Examples
The following example shows how to navigate to a Page object containing the source content tree.

void goObjectButton_Click(object sender, RoutedEventArgs e)


{
this.NavigationService.Navigate(new ContentPage());
}

Remarks
Navigate will navigate to the Object specified by root if the following conditions are true:

The Navigating event is not cancelled.


A web request (see Navigating) can be created.
If root is null , the existing content (Content) is cleared.
Note

When downloading Web content, you may receive a Web exception (for example, 404: File Not Found). You can handle
such exceptions from NavigationFailed.
See Navigate(Uri)Navigate(Uri)
Also Navigate(Uri, Object)Navigate(Uri, Object)
Navigate(Uri, Object, Boolean)Navigate(Uri, Object, Boolean)
Navigate(Object, Object)Navigate(Object, Object)

Navigate(Object, Object) Navigate(Object, Object)


Navigate asynchronously to content that is contained by an object, and pass an object that contains data to be used for
processing during navigation.
public bool Navigate (object root, object navigationState);
member this.Navigate : obj * obj -> bool

Parameters
root Object Object
An object that contains the content to navigate to.
navigationState Object Object
An object that contains data to be used for processing during navigation.
Returns
Boolean Boolean
true if a navigation is not canceled; otherwise, false .
Examples
The following example shows how to navigate to a Page object containing the source content, and passing navigation
state.

void goButton_Click(object sender, RoutedEventArgs e)


{
this.NavigationService.Navigate(new ContentPage(), DateTime.Now);
}
void NavigationService_LoadCompleted(object sender, NavigationEventArgs e)
{
DateTime requestDateTime = (DateTime)e.ExtraData;
string msg = string.Format("Request started {0}
Request completed {1}", requestDateTime, DateTime.Now);
MessageBox.Show(msg);
}

Remarks
This method has the same behavior as NavigationService.Navigate, although an object is passed instead of a URI.
See Navigate(Uri)Navigate(Uri)
Also Navigate(Uri, Object)Navigate(Uri, Object)
Navigate(Uri, Object, Boolean)Navigate(Uri, Object, Boolean)
Navigate(Object)Navigate(Object)
NavigationService.Navigated NavigationService.
Navigated
I n this Article
Occurs when the content that is being navigated to has been found, and is available from the Content property,
although it may not have completed loading.
public event System.Windows.Navigation.NavigatedEventHandler Navigated;
member this.Navigated : System.Windows.Navigation.NavigatedEventHandler

Examples
The following example shows how to handle Navigated.

void NavigationService_Navigated(object sender, NavigationEventArgs e)


{
string msg = string.Format("Downloading {0}.", e.Uri.OriginalString);
this.progressStatusBarItem.Content = msg;
}

Remarks
You handle Navigated if you need to discover pertinent information regarding the navigation request when
downloading commences. This information is available from the NavigationEventArgs object that is passed to the
Navigated event handler, and includes:
The source page. When Navigated is raised, at least part of the source page's user interface (UI) tree has been parsed,
and attached to target content control.
The requested URI.
The navigator (NavigationWindow, Frame).
Additional data, if the navigation was initiated by calling either Navigate or Navigate.
Response details (using a WebResponse object).
Navigated is not raised when the source page could not be found or loaded, in which case NavigationFailed is raised.
Note

When NavigationService raises NavigationFailed, it also raises Application.NavigationFailed event on the Application
object.
See NavigatingNavigating
Also LoadCompletedLoadCompleted
NavigationProgressNavigationProgress
NavigationStoppedNavigationStopped
FragmentNavigationFragmentNavigation
NavigationFailedNavigationFailed
NavigationService.Navigating NavigationService.
Navigating
I n this Article
Occurs when a new navigation is requested.

public event System.Windows.Navigation.NavigatingCancelEventHandler Navigating;


member this.Navigating : System.Windows.Navigation.NavigatingCancelEventHandler

Examples
The following example shows how to handle Navigating to detect whether a request to refresh static content has been
made and, if so, to cancel the request.
Navigating.
void NavigationService_Navigating(object sender, NavigatingCancelEventArgs e)
{
// Don't allow refreshing of a static page
if ((e.NavigationMode == NavigationMode.Refresh) &&
(e.Uri.OriginalString == "StaticPage.xaml"))
{
e.Cancel = true;
}
}

Remarks
Navigating is raised when a new navigation is requested, but before the source content is requested, including when:
Navigate is called.
GoBack or GoForward is called (or an entry is selected from a navigation UI).
A content fragment is navigated to.
You handle Navigating if you need to discover pertinent information regarding the navigation request before
navigation starts. This information is available from the NavigatingCancelEventArgs object that is passed to the
Navigating event handler.
A WebRequest object for the navigation is created and available from the NavigatingCancelEventArgs parameter;
because the actual request hasn't been made at this point, you can reconfigure the WebRequest object, if necessary.
You also handle NavigatingCancelEventArgs to cancel navigation, if required, by setting Cancel to true. If you cancel
navigation, no other navigation events are raised.
Note

If your application is hosted in the browser, you cannot prevent the user from navigating away from your application
by canceling the Navigating event.
After the first piece of content is navigated to by a navigator (NavigationWindow, Frame), each piece of content that is
navigated away from is added to navigation history. If you need to save state information about the content you are
navigating away from, you can add the state to the journal entry for that content by setting ContentStateToSave with a
CustomContentState object.
Note

When NavigationService raises Navigating, it also raises Application.Navigating event on the Application object.
See FragmentNavigationFragmentNavigation
Also NavigatedNavigated
LoadCompletedLoadCompleted
NavigationProgressNavigationProgress
NavigationStoppedNavigationStopped
NavigationFailedNavigationFailed
Refresh()Refresh()
NavigationService.NavigationFailed NavigationService.
NavigationFailed
I n this Article
Occurs when an error occurs while navigating to the requested content.

public event System.Windows.Navigation.NavigationFailedEventHandler NavigationFailed;


member this.NavigationFailed : System.Windows.Navigation.NavigationFailedEventHandler

Examples
The following example shows how to handle NavigationFailed.
void NavigationService_NavigationFailed(object sender, NavigationFailedEventArgs e)
{
string msg = string.Format("Navigation to {0} failed: {1}.", e.Uri.OriginalString,
e.Exception.Message);
this.progressStatusBarItem.Content = msg;
}

Remarks
When either a WebException or an IOException is thrown during a navigation, the NavigationFailed event is raised.
NavigationFailed is passed a NavigationFailedEventArgs that encapsulates information about both the exception and
the details of the navigation that caused the exception.
When an exception results from a failed navigation, and is unhandled, the following events are raised in the order
listed:
NavigationService.NavigationFailed.
Frame.NavigationFailed or NavigationWindow.NavigationFailed.
Application.NavigationFailed.
DispatcherUnhandledException.
If a navigator (NavigationWindow, Frame) is hosted by one or more navigators, NavigationFailed is not raised on
any of them.
See FragmentNavigationFragmentNavigation
Also NavigatingNavigating
NavigatedNavigated
LoadCompletedLoadCompleted
NavigationProgressNavigationProgress
NavigationStoppedNavigationStopped
Refresh()Refresh()
NavigationService.NavigationProgress Navigation
Service.NavigationProgress
I n this Article
Occurs periodically during a download to provide navigation progress information.

public event System.Windows.Navigation.NavigationProgressEventHandler NavigationProgress;


member this.NavigationProgress : System.Windows.Navigation.NavigationProgressEventHandler

Examples
The following example shows how to handle NavigationProgress.
void NavigationService_NavigationProgress(object sender, NavigationProgressEventArgs e)
{
string msg = string.Format("{0} of {1} bytes retrieved.", e.BytesRead, e.MaxBytes);
this.progressStatusBarItem.Content = msg;
}

Remarks
NavigationProgress is passed a NavigationProgressEventArgs which exposes the following progress information:
Number of bytes downloaded so far (BytesRead).
Number of total bytes to download (MaxBytes).
NavigationProgress is raised once for every 1024 bytes of content downloaded, and once more if the number of
remaining bytes is ever less than 1024 bytes. For this reason, handling NavigationProgress provides a useful way to
track and display the progress of a current download.
NavigationProgress won't be raised in some cases, such as when the same piece of content is navigated to, or when a
content fragment is navigated to on content that is currently loaded (that is, the value of the Content property).
When navigating to a compiled XAML resource, the final NavigationProgress event may not be raised. This means that
at the end of the download, the last reported BytesRead value may not equal the MaxBytes value. Handle the
LoadCompleted event to be notified when the navigation has finished.
Note

When NavigationService raises NavigationProgress, it also raises Application.NavigationProgress event on the


Application object.
See FragmentNavigationFragmentNavigation
Also NavigatingNavigating
NavigatedNavigated
LoadCompletedLoadCompleted
NavigationStoppedNavigationStopped
NavigationFailedNavigationFailed
NavigationService.NavigationStopped Navigation
Service.NavigationStopped
I n this Article
Occurs when the StopLoading() method is called, or when a new navigation is requested while a current navigation is
in progress.
public event System.Windows.Navigation.NavigationStoppedEventHandler NavigationStopped;
member this.NavigationStopped : System.Windows.Navigation.NavigationStoppedEventHandler

Examples
The following example shows how to handle NavigationStopped.

void NavigationService_NavigationStopped(object sender, NavigationEventArgs e)


{
this.progressStatusBarItem.Content = "Navigation stopped.";
}

Remarks
You handle NavigationStopped if you need to discover pertinent information regarding the navigation request when
downloading is stopped. This information is available from the NavigationEventArgs object that is passed to the
NavigationStopped event handler, and includes:
The requested URI.
The navigator (NavigationWindow, Frame).
Additional data, if the navigation was initiated by calling either NavigationService.Navigate or
NavigationService.Navigate.
Note

When NavigationService raises NavigationStopped, it also raises Application.NavigationStopped event on the


Application object.
See FragmentNavigationFragmentNavigation
Also NavigatingNavigating
NavigatedNavigated
LoadCompletedLoadCompleted
NavigationProgressNavigationProgress
NavigationFailedNavigationFailed
NavigationService.Refresh NavigationService.Refresh
I n this Article
Reloads the current content.
public void Refresh ();
member this.Refresh : unit -> unit

Remarks
If the current content (specified by the value of the Source property) is navigated to again, NavigationService does not
download the content again. To force NavigationService to re-navigate to the content, call Refresh.
Note that if the current content is navigated to again, whether by calling Navigate or Refresh, a new entry is not added
to navigation history.
See NavigatingNavigating
Also
NavigationService.RemoveBackEntry NavigationService.
RemoveBackEntry
I n this Article
Removes the most recent journal entry from back history.

public System.Windows.Navigation.JournalEntry RemoveBackEntry ();


member this.RemoveBackEntry : unit -> System.Windows.Navigation.JournalEntry

Returns
JournalEntry JournalEntry
The most recent JournalEntry in back navigation history, if there is one.

Remarks
If two or more navigators (NavigationWindow, Frame) share the same navigation history, one navigator can use
RemoveBackEntry to retrieve the back navigation history entry for a navigation that took place in another navigator.
See AddBackEntry(CustomContentState)AddBackEntry(CustomContentState)
Also
NavigationService.Source NavigationService.Source
I n this Article
Gets or sets the URI of the current content, or the URI of new content that is currently being navigated to.
public Uri Source { get; set; }
member this.Source : Uri with get, set

Returns
Uri Uri
A Uri that contains the URI for the current content, or the content that is currently being navigated to.

Remarks
If you set this property to a different URI than the one currently being displayed, the navigator ( NavigationWindow,
Frame) navigates to the specified URI.
Source is set to the content that is loaded from the URI that is navigated to, unless the navigation is canceled.
Source can be set with a fragment-only URI, and can be set to null .
NavigationService.StopLoading NavigationService.Stop
Loading
I n this Article
Stops further downloading of content for the current navigation request.

public void StopLoading ();


member this.StopLoading : unit -> unit

Examples
The following example demonstrates how to stop loading.
void stopButton_Click(object sender, RoutedEventArgs e)
{
this.NavigationService.StopLoading();
}

Remarks
StopLoading can be called as soon as Navigate returns, and stops navigation that is in progress in child frames.
(Frame).

Calling the StopLoading method raises the NavigationStopped event.


Note

StopLoading must be called on the same thread that initiated the navigation.
See NavigateNavigate
Also
NavigationStoppedEventHandler NavigationStopped
EventHandler Delegate
Represents the method that will handle NavigationStopped events.

D eclaration
public delegate void NavigationStoppedEventHandler(object sender, NavigationEventArgs e);
type NavigationStoppedEventHandler = delegate of obj * NavigationEventArgs -> unit

I nheritance H ierarchy
Object Object
Delegate Delegate

Remarks
This event handler is used for the following events:
NavigationService.NavigationStopped
NavigationWindow.NavigationStopped
Frame.NavigationStopped
Application.NavigationStopped
NavigationUIVisibility NavigationUIVisibility Enum
Specifies whether a Frame displays its navigation chrome. NavigationUIVisibility is used by the NavigationUIVisibility
property.

D eclaration
public enum NavigationUIVisibility
type NavigationUIVisibility =

I nheritance H ierarchy
Object Object
ValueType ValueType
Enum Enum

Fields
Automatic Automatic The navigation chrome is visible when a Frame uses its own journal (see JournalOwnership).

Hidden Hidden The navigation chrome is not visible.

Visible Visible The navigation chrome is visible.


NavigationWindow NavigationWindow Class
Represents a window that supports content navigation.

D eclaration
[System.Windows.Markup.ContentProperty]
[System.Windows.TemplatePart(Name="PART_NavWinCP",
Type=typeof(System.Windows.Controls.ContentPresenter))]
public class NavigationWindow : System.Windows.Window, System.Windows.Markup.IUriContext
type NavigationWindow = class
inherit Window
interface IUriContext

I nheritance H ierarchy
Object Object
DispatcherObject DispatcherObject
DependencyObject DependencyObject
Visual Visual
UIElement UIElement
FrameworkElement FrameworkElement
Control Control
ContentControl ContentControl
Window Window

Remarks
NavigationWindow derives from Window and extends it with the ability to navigate to and display content.
Content can be any .NET Framework object or HTML file. In general, however, a Page object is the preferred way to
package content for navigation.
Content can be navigated to by setting the Source property with the URI for the desired content. Additionally, content
can be navigated to by using one of the following overloads of the Navigate method:
Navigate(Uri)
Navigate(Uri, Object)
When content is navigated to by URI, NavigationWindow will return an object that contains the content.
Note

Navigation by URI also supports navigation to a content fragment. See FragmentNavigation.


Alternatively, content can be navigated to by using one of the Navigate method overloads that accepts an object:
Navigate(Object)
Navigate(Object, Object)
The lifetime of a navigation can be tracked through the following events:
Navigating
Navigated
NavigationProgress
NavigationFailed
NavigationStopped
LoadCompleted
FragmentNavigation.
Not all events are raised each time that a navigation occurs; the set of events that are raised is determined by the type
of navigation that occurs (content or content fragment) and how the navigation completes (canceled, stopped, or
failed).
The following figure illustrates the sequence in which these events will fire:

During or after a navigation, NavigationWindow provides information about the content that is being navigated to,
including the URI of the content being navigated to (Source), the URI of the current content (CurrentSource), and an
object that contains the content that was navigated to (Content).
When content is navigated to, NavigationWindow records the navigation as an entry in navigation history. An entry is
added to back navigation history when either a new navigation occurs, by calling the Navigate method, or by
navigating to an entry in forward navigation history, by calling GoForward. An entry is added to forward navigation
history by navigating to an entry in back navigation history, by calling GoBack. CanGoBack and CanGoForward report
whether there are entries in backward and forward navigation history, respectively.
The first time that one piece of content is navigated to from another piece of content, NavigationWindow automatically
displays a navigation UI that allows users to navigate back and forwards through navigation history. You can configure
when the navigation UI is shown by setting the ShowsNavigationUI property.
The most recent entry in back navigation history can be removed by calling RemoveBackEntry.
NavigationWindow does not store an instance of a content object in navigation history. Instead, NavigationWindow
creates a new instance of the content object each time it is navigated to by using navigation history. This behavior is
designed to avoid excessive memory consumption when large numbers and large pieces of content are being
navigated to. Consequently, the state of the content is not remembered from one navigation to the next. However,
WPF provides several techniques by which you can store a piece of state for a piece of content in navigation history.
Using AddBackEntry, you can also remember multiple sets of state for a single page instance.
NavigationWindow is one of two navigators in WPF, the other being Frame. Essentially, navigator is a class supports
navigation and navigation history. Visually, XBAPs use Internet Explorer 7 as a navigator, to provide an integrated user
experience. However, XBAPs actually use NavigationWindow as the navigator; the MainWindow property of an XBAP
running in Internet Explorer 7 will return a reference to the NavigationWindow, and the navigation history that is
managed by the NavigationWindow is integrated with the navigation history that is managed by Internet Explorer 7.
Content Model: NavigationWindow is a ContentControl, which means that NavigationWindow can contain content
such as text, images, or panels. Also, NavigationWindow is a root element and, consequently, cannot be part of another
element's content. For more information about the content model for Button, see WPF Content Model.
Customizing the NavigationWindow Control
To apply the same property settings to multiple NavigationWindow controls, use the Style property. You can modify
the default ControlTemplate to give the control a unique appearance. For more information about creating a
ControlTemplate, see Customizing the Appearance of an Existing Control by Creating a ControlTemplate. To see the
parts and states that are specific to the NavigationWindow, see NavigationWindow Styles and Templates.
Dependency properties for this control might be set by the control's default style. If a property is set by a default style,
the property might change from its default value when the control appears in the application. The default style is
determined by which desktop theme is used when the application is running. For more information, see Default WPF
Themes.
Note

Setting a visual property only has an effect if that property is both present in the control's default template and is set
by using a TemplateBinding. You can find a list of visual properties in the Changing the Visual Structure of a Control
section in the Customizing the Appearance of an Existing Control by Creating a ControlTemplate article.

Constructors
NavigationWindow()
NavigationWindow()

Initializes a new instance of the NavigationWindow class.

Fields
BackStackProperty
BackStackProperty

Identifies the BackStack dependency property.

CanGoBackProperty
CanGoBackProperty

Identifies the CanGoBack dependency property.

CanGoForwardProperty
CanGoForwardProperty

Identifies the CanGoForward dependency property.

ForwardStackProperty
ForwardStackProperty
Identifies the ForwardStack dependency property.

SandboxExternalContentProperty
SandboxExternalContentProperty

Identifies the SandboxExternalContent dependency property.

ShowsNavigationUIProperty
ShowsNavigationUIProperty

Identifies the ShowsNavigationUI dependency property.

SourceProperty
SourceProperty

Identifies the Source dependency property.

Properties
BackStack
BackStack

Gets an IEnumerable that you use to enumerate the entries in back navigation history for a NavigationWindow.

CanGoBack
CanGoBack

Gets a value that indicates whether there is at least one entry in back navigation history.

CanGoForward
CanGoForward

Gets a value that indicates whether there is at least one entry in forward navigation history.

CurrentSource
CurrentSource

Gets the uniform resource identifier (URI) of the content that was last navigated to.

ForwardStack
ForwardStack

Gets an IEnumerable that you use to enumerate the entries in back navigation history for a NavigationWindow.
NavigationService
NavigationService

Gets the NavigationService that is used by this NavigationWindow to provide navigation services to its content.

SandboxExternalContent
SandboxExternalContent

Gets or sets a value that indicates whether a NavigationWindow isolates external Extensible Application Markup
Language (XAML ) content within a partial trust security sandbox (with default Internet zone permission set).

ShowsNavigationUI
ShowsNavigationUI

Gets or sets a value that indicates whether a NavigationWindow shows its navigation UI.

Source
Source

Gets or sets the uniform resource identifier (URI) of the current content, or the URI of new content that is
currently being navigated to.

Methods
AddBackEntry(CustomContentState)
AddBackEntry(CustomContentState)

Adds an entry to back navigation history that contains a CustomContentState object.

AddChild(Object)
AddChild(Object)

Adds a child object.

AddText(String)
AddText(String)

Adds text to the object.

GoBack()
GoBack()

Navigates to the most recent item in back navigation history.

GoForward()
GoForward()

Navigates to the most recent item in forward navigation history.

Navigate(Object, Object)
Navigate(Object, Object)

Navigates asynchronously to content that is contained by an object, and passes an object that contains data to be
used for processing during navigation.

Navigate(Uri, Object)
Navigate(Uri, Object)

Navigates asynchronously to source content located at a uniform resource identifier (URI), and pass an object that
contains data to be used for processing during navigation.

Navigate(Object)
Navigate(Object)

Navigates asynchronously to content that is contained by an object.

Navigate(Uri)
Navigate(Uri)

Navigates asynchronously to content that is specified by a uniform resource identifier (URI).

OnApplyTemplate()
OnApplyTemplate()

Called when the template generation for the visual tree is created.

OnClosed(EventArgs)
OnClosed(EventArgs)

Raises the Closed event.

OnCreateAutomationPeer()
OnCreateAutomationPeer()

Creates and returns a NavigationWindowAutomationPeer object for this NavigationWindow.

Refresh()
Refresh()

Reloads the current content.


RemoveBackEntry()
RemoveBackEntry()

Removes the most recent journal entry from back history.

ShouldSerializeContent()
ShouldSerializeContent()

Indicates whether the Content property should be persisted.

StopLoading()
StopLoading()

Stops further downloading of content for the current navigation request.

Events
FragmentNavigation
FragmentNavigation

Occurs when navigation to a content fragment begins, which occurs immediately, if the desired fragment is in the
current content, or after the source XAML content has been loaded, if the desired fragment is in different content.

LoadCompleted
LoadCompleted

Occurs when content that was navigated to has been loaded, parsed, and has begun rendering.

Navigated
Navigated

Occurs when the content that is being navigated to has been found, and is available from the Content property,
although it may not have completed loading.

Navigating
Navigating

Occurs when a new navigation is requested.

NavigationFailed
NavigationFailed

Occurs when an error is raised while navigating to the requested content.

NavigationProgress
NavigationProgress

Occurs periodically during a download to provide navigation progress information.

NavigationStopped
NavigationStopped

Occurs when the StopLoading() method is called, or when a new navigation is requested while a current
navigation is in progress.

IUriContext.BaseUri
IUriContext.BaseUri

Gets or sets the base uniform resource identifier (URI) of the current context.
NavigationWindow.AddBackEntry NavigationWindow.
AddBackEntry
I n this Article
Adds an entry to back navigation history that contains a CustomContentState object.

public void AddBackEntry (System.Windows.Navigation.CustomContentState state);


abstract member AddBackEntry : System.Windows.Navigation.CustomContentState -> unit
override this.AddBackEntry : System.Windows.Navigation.CustomContentState -> unit

Parameters
state CustomContentState CustomContentState
A CustomContentState object that represents application-defined state that is associated with a specific piece of
content.
Exceptions
InvalidOperationException InvalidOperationException
state is null , and a CustomContentState object isn't returned from GetContentState().

Remarks
See NavigationService.AddBackEntry.
NavigationWindow.AddChild NavigationWindow.Add
Child
I n this Article
Adds a child object.

protected override void AddChild (object value);


override this.AddChild : obj -> unit

Parameters
value Object Object
The child object to add.
Exceptions
InvalidOperationException InvalidOperationException
when this method is called. This prevents content from being added to NavigationWindow using XAML.
NavigationWindow.AddText NavigationWindow.AddText
I n this Article
Adds text to the object.
protected override void AddText (string text);
override this.AddText : string -> unit

Parameters
text String String
The text to add to the object.
Exceptions
ArgumentException ArgumentException
if the text parameter value contains non-white-space characters.
NavigationWindow.BackStack NavigationWindow.Back
Stack
I n this Article
Gets an IEnumerable that you use to enumerate the entries in back navigation history for a NavigationWindow.

public System.Collections.IEnumerable BackStack { get; }


member this.BackStack : System.Collections.IEnumerable

Returns
IEnumerable IEnumerable
IEnumerable if at least one entry has been added to back navigation history, or null if there are not entries or the
NavigationWindow does not own its own navigation history.

Remarks
The entries that are returned by BackStack include whole content, fragment navigations, and custom state.
D ependency P roperty I nformation

Identifier field BackStack

Metadata properties set to true None

See FragmentNavigationFragmentNavigation
Also CustomContentStateCustomContentState
NavigationWindow.BackStackProperty Navigation
Window.BackStackProperty
I n this Article
Identifies the BackStack dependency property.

public static readonly System.Windows.DependencyProperty BackStackProperty;


staticval mutable BackStackProperty : System.Windows.DependencyProperty

Returns
DependencyProperty DependencyProperty
NavigationWindow.CanGoBack NavigationWindow.Can
GoBack
I n this Article
Gets a value that indicates whether there is at least one entry in back navigation history.

public bool CanGoBack { get; }


member this.CanGoBack : bool

Returns
Boolean Boolean
true if there is at least one entry in back navigation history; false if there are no entries in back navigation history or
the NavigationWindow does not own its own navigation history.

Remarks
See NavigationService.CanGoBack.
D ependency P roperty I nformation

Identifier field CanGoBack

Metadata properties set to true None

See GoBack()GoBack()
Also CanGoForwardCanGoForward
GoForward()GoForward()
NavigationWindow.CanGoBackProperty Navigation
Window.CanGoBackProperty
I n this Article
Identifies the CanGoBack dependency property.

public static readonly System.Windows.DependencyProperty CanGoBackProperty;


staticval mutable CanGoBackProperty : System.Windows.DependencyProperty

Returns
DependencyProperty DependencyProperty
NavigationWindow.CanGoForward NavigationWindow.
CanGoForward
I n this Article
Gets a value that indicates whether there is at least one entry in forward navigation history.

public bool CanGoForward { get; }


member this.CanGoForward : bool

Returns
Boolean Boolean
true if there is at least one entry in forward navigation history; false if there are no entries in forward navigation
history, or the NavigationWindow does not own its own navigation history.

Remarks
D ependency P roperty I nformation

Identifier field CanGoForward

Metadata properties set to true None

See GoForward()GoForward()
Also GoBack()GoBack()
CanGoForwardCanGoForward
NavigationWindow.CanGoForwardProperty Navigation
Window.CanGoForwardProperty
I n this Article
Identifies the CanGoForward dependency property.

public static readonly System.Windows.DependencyProperty CanGoForwardProperty;


staticval mutable CanGoForwardProperty : System.Windows.DependencyProperty

Returns
DependencyProperty DependencyProperty
NavigationWindow.CurrentSource NavigationWindow.
CurrentSource
I n this Article
Gets the uniform resource identifier (URI) of the content that was last navigated to.

public Uri CurrentSource { get; }


member this.CurrentSource : Uri

Returns
Uri Uri
The URI for the content that was last navigated to, if navigated to by using a URI; otherwise, null .

Remarks
See NavigationWindow.CurrentSource.
NavigationWindow.ForwardStack NavigationWindow.
ForwardStack
I n this Article
Gets an IEnumerable that you use to enumerate the entries in back navigation history for a NavigationWindow.

public System.Collections.IEnumerable ForwardStack { get; }


member this.ForwardStack : System.Collections.IEnumerable

Returns
IEnumerable IEnumerable
IEnumerable if at least one entry has been added to forward navigation history, or null if there are no entries or the
NavigationWindow does not own its own navigation history.

Remarks
The entries that are returned by ForwardStack include whole content, fragment navigations, and custom state.
D ependency P roperty I nformation

Identifier field ForwardStack

Metadata properties set to true None

See FragmentNavigationFragmentNavigation
Also CustomContentStateCustomContentState
NavigationWindow.ForwardStackProperty Navigation
Window.ForwardStackProperty
I n this Article
Identifies the ForwardStack dependency property.

public static readonly System.Windows.DependencyProperty ForwardStackProperty;


staticval mutable ForwardStackProperty : System.Windows.DependencyProperty

Returns
DependencyProperty DependencyProperty
NavigationWindow.FragmentNavigation Navigation
Window.FragmentNavigation
I n this Article
Occurs when navigation to a content fragment begins, which occurs immediately, if the desired fragment is in the
current content, or after the source XAML content has been loaded, if the desired fragment is in different content.
public event System.Windows.Navigation.FragmentNavigationEventHandler FragmentNavigation;
member this.FragmentNavigation : System.Windows.Navigation.FragmentNavigationEventHandler

Remarks
See NavigationService.FragmentNavigation.
See NavigatingNavigating
Also NavigatedNavigated
LoadCompletedLoadCompleted
NavigationProgressNavigationProgress
NavigationStoppedNavigationStopped
NavigationFailedNavigationFailed
NavigationWindow.GoBack NavigationWindow.GoBack
I n this Article
Navigates to the most recent item in back navigation history.
public void GoBack ();
abstract member GoBack : unit -> unit
override this.GoBack : unit -> unit

Exceptions
InvalidOperationException InvalidOperationException
GoBack() is called when there are no entries in back navigation history.
See CanGoBackCanGoBack
Also CanGoForwardCanGoForward
GoForward()GoForward()
NavigationWindow.GoForward NavigationWindow.Go
Forward
I n this Article
Navigates to the most recent item in forward navigation history.

public void GoForward ();


abstract member GoForward : unit -> unit
override this.GoForward : unit -> unit

Exceptions
InvalidOperationException InvalidOperationException
GoForward() is called when there are no entries in forward navigation history.
See CanGoForwardCanGoForward
Also CanGoBackCanGoBack
GoBack()GoBack()
NavigationWindow.IUriContext.BaseUri
I n this Article
Gets or sets the base uniform resource identifier (URI) of the current context.
Uri System.Windows.Markup.IUriContext.BaseUri { get; set; }

Returns
Uri
The base URI of the current context.

Remarks
This member is an explicit interface member implementation. It can be used only when the NavigationWindow
instance is cast to an IUriContext interface.
NavigationWindow.LoadCompleted NavigationWindow.
LoadCompleted
I n this Article
Occurs when content that was navigated to has been loaded, parsed, and has begun rendering.

public event System.Windows.Navigation.LoadCompletedEventHandler LoadCompleted;


member this.LoadCompleted : System.Windows.Navigation.LoadCompletedEventHandler

Remarks
See NavigationService.LoadCompleted.
See NavigatingNavigating
Also NavigatedNavigated
NavigationProgressNavigationProgress
NavigationStoppedNavigationStopped
NavigationFailedNavigationFailed
FragmentNavigationFragmentNavigation
NavigationWindow.Navigate NavigationWindow.
Navigate
I n this Article

Overloads
Navigate(Object, Object) Navigate(Object, Object)
Navigates asynchronously to content that is contained by an
object, and passes an object that contains data to be used for
processing during navigation.

Navigate(Uri, Object) Navigate(Uri, Object)


Navigates asynchronously to source content located at a
uniform resource identifier (URI), and pass an object that
contains data to be used for processing during navigation.

Navigate(Object) Navigate(Object)
Navigates asynchronously to content that is contained by an
object.

Navigate(Uri) Navigate(Uri)
Navigates asynchronously to content that is specified by a
uniform resource identifier (URI).

Navigate(Object, Object) Navigate(Object, Object)


Navigates asynchronously to content that is contained by an object, and passes an object that contains data to be used
for processing during navigation.
public bool Navigate (object content, object extraData);
abstract member Navigate : obj * obj -> bool
override this.Navigate : obj * obj -> bool

Parameters
content Object Object
An Object that contains the content to navigate to.
extraData Object Object
A Object that contains data to be used for processing during navigation.
Returns
Boolean Boolean
true if a navigation is not canceled; otherwise, false .
Remarks
See NavigationService.Navigate(Object, Object).
See Navigate(Uri)Navigate(Uri)
Also Navigate(Uri, Object)Navigate(Uri, Object)
Navigate(Object)Navigate(Object)

Navigate(Uri, Object) Navigate(Uri, Object)


Navigates asynchronously to source content located at a uniform resource identifier (URI), and pass an object that
contains data to be used for processing during navigation.
public bool Navigate (Uri source, object extraData);
abstract member Navigate : Uri * obj -> bool
override this.Navigate : Uri * obj -> bool

Parameters
source Uri Uri
A Uri object initialized with the URI for the desired content.
extraData Object Object
A Object that contains data to be used for processing during navigation.
Returns
Boolean Boolean
true if a navigation is not canceled; otherwise, false .
Remarks
See NavigationService.Navigate(Uri, Object).
See Navigate(Uri)Navigate(Uri)
Also Navigate(Object)Navigate(Object)
Navigate(Object, Object)Navigate(Object, Object)

Navigate(Object) Navigate(Object)
Navigates asynchronously to content that is contained by an object.

public bool Navigate (object content);


abstract member Navigate : obj -> bool
override this.Navigate : obj -> bool

Parameters
content Object Object
An Object that contains the content to navigate to.
Returns
Boolean Boolean
true if a navigation is not canceled; otherwise, false .
Examples
The following example shows how to navigate to content that is contained by an object.

// Navigate to object using the Navigate method


this.Navigate(new HomePage());
Remarks
See NavigationService.Navigate(Object).
See Navigate(Uri)Navigate(Uri)
Also Navigate(Uri, Object)Navigate(Uri, Object)
Navigate(Object, Object)Navigate(Object, Object)

Navigate(Uri) Navigate(Uri)
Navigates asynchronously to content that is specified by a uniform resource identifier (URI).
public bool Navigate (Uri source);
abstract member Navigate : Uri -> bool
override this.Navigate : Uri -> bool

Parameters
source Uri Uri
A Uri object initialized with the URI for the desired content.
Returns
Boolean Boolean
true if a navigation is not canceled; otherwise, false .
Examples
The following example shows how to use the Navigate method to navigate to a uniform resource identifier (URI).
// Navigate to URI using the Navigate method
this.Navigate(new Uri("HomePage.xaml", UriKind.Relative));

Remarks
See NavigationService.Navigate(Uri).
Note

Uniform resource identifiers (URIs) can be either relative or absolute. For more information, see Pack URIs in WPF.
See Navigate(Uri, Object)Navigate(Uri, Object)
Also Navigate(Object)Navigate(Object)
Navigate(Object, Object)Navigate(Object, Object)
NavigationWindow.Navigated NavigationWindow.
Navigated
I n this Article
Occurs when the content that is being navigated to has been found, and is available from the Content property,
although it may not have completed loading.
public event System.Windows.Navigation.NavigatedEventHandler Navigated;
member this.Navigated : System.Windows.Navigation.NavigatedEventHandler

Remarks
See NavigationService.Navigated.
See NavigatingNavigating
Also LoadCompletedLoadCompleted
NavigationProgressNavigationProgress
NavigationStoppedNavigationStopped
NavigationFailedNavigationFailed
FragmentNavigationFragmentNavigation
NavigationWindow.Navigating NavigationWindow.
Navigating
I n this Article
Occurs when a new navigation is requested.

public event System.Windows.Navigation.NavigatingCancelEventHandler Navigating;


member this.Navigating : System.Windows.Navigation.NavigatingCancelEventHandler

Remarks
See NavigationService.Navigating.
See NavigatedNavigated
Also LoadCompletedLoadCompleted
NavigationProgressNavigationProgress
NavigationStoppedNavigationStopped
NavigationFailedNavigationFailed
FragmentNavigationFragmentNavigation
NavigationWindow.NavigationFailed NavigationWindow.
NavigationFailed
I n this Article
Occurs when an error is raised while navigating to the requested content.

public event System.Windows.Navigation.NavigationFailedEventHandler NavigationFailed;


member this.NavigationFailed : System.Windows.Navigation.NavigationFailedEventHandler

Remarks
See NavigationService.NavigationFailed.
See NavigatingNavigating
Also NavigatedNavigated
LoadCompletedLoadCompleted
NavigationProgressNavigationProgress
NavigationStoppedNavigationStopped
FragmentNavigationFragmentNavigation
NavigationWindow.NavigationProgress Navigation
Window.NavigationProgress
I n this Article
Occurs periodically during a download to provide navigation progress information.

public event System.Windows.Navigation.NavigationProgressEventHandler NavigationProgress;


member this.NavigationProgress : System.Windows.Navigation.NavigationProgressEventHandler

Remarks
See NavigationService.NavigationProgress.
See NavigatingNavigating
Also NavigatedNavigated
LoadCompletedLoadCompleted
NavigationStoppedNavigationStopped
NavigationFailedNavigationFailed
FragmentNavigationFragmentNavigation
NavigationWindow.NavigationService Navigation
Window.NavigationService
I n this Article
Gets the NavigationService that is used by this NavigationWindow to provide navigation services to its content.

public System.Windows.Navigation.NavigationService NavigationService { get; }


member this.NavigationService : System.Windows.Navigation.NavigationService

Returns
NavigationService NavigationService
The navigation service used by this NavigationWindow.

Remarks
NavigationWindow uses a NavigationService to provide navigation services to content that is hosted by
NavigationWindow. The NavigationService property is useful for code in a custom NavigationWindow to get a
reference to the NavigationService, to handle navigation events, for example.
Content that is hosted by a NavigationWindow, such as Page, should use the NavigationService.GetNavigationService
method or Page.NavigationService property to get a reference to the NavigationService.
NavigationWindow.NavigationStopped Navigation
Window.NavigationStopped
I n this Article
Occurs when the StopLoading() method is called, or when a new navigation is requested while a current navigation is
in progress.
public event System.Windows.Navigation.NavigationStoppedEventHandler NavigationStopped;
member this.NavigationStopped : System.Windows.Navigation.NavigationStoppedEventHandler

Remarks
See NavigationService.NavigationStopped.
See NavigatingNavigating
Also NavigatedNavigated
LoadCompletedLoadCompleted
NavigationProgressNavigationProgress
NavigationFailedNavigationFailed
FragmentNavigationFragmentNavigation
NavigationWindow
I n this Article
Initializes a new instance of the NavigationWindow class.
public NavigationWindow ();
NavigationWindow.OnApplyTemplate Navigation
Window.OnApplyTemplate
I n this Article
Called when the template generation for the visual tree is created.

[System.Security.SecurityCritical]
public override void OnApplyTemplate ();
override this.OnApplyTemplate : unit -> unit

Attributes SecurityCriticalAttribute
NavigationWindow.OnClosed NavigationWindow.On
Closed
I n this Article
Raises the Closed event.

protected override void OnClosed (EventArgs args);


override this.OnClosed : EventArgs -> unit

Parameters
args EventArgs EventArgs
An EventArgs that contains the event data.

Remarks
OnClosed releases the NavigationService object that it is using to manage navigation, before raising Closed event.
NavigationWindow.OnCreateAutomationPeer Navigation
Window.OnCreateAutomationPeer
I n this Article
Creates and returns a NavigationWindowAutomationPeer object for this NavigationWindow.

protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer ();


override this.OnCreateAutomationPeer : unit -> System.Windows.Automation.Peers.AutomationPeer

Returns
AutomationPeer AutomationPeer
A NavigationWindowAutomationPeer object for this NavigationWindow.

Remarks
This method overrides OnCreateAutomationPeer.
NavigationWindow.Refresh NavigationWindow.Refresh
I n this Article
Reloads the current content.
public void Refresh ();
abstract member Refresh : unit -> unit
override this.Refresh : unit -> unit

Examples
The following example shows how to call the Refresh method to reload the content in a NavigationWindow.
void navigateRefreshButton_Click(object sender, RoutedEventArgs e)
{
this.Refresh();
}

Remarks
See NavigationService.Refresh.
NavigationWindow.RemoveBackEntry Navigation
Window.RemoveBackEntry
I n this Article
Removes the most recent journal entry from back history.

public System.Windows.Navigation.JournalEntry RemoveBackEntry ();


abstract member RemoveBackEntry : unit -> System.Windows.Navigation.JournalEntry
override this.RemoveBackEntry : unit -> System.Windows.Navigation.JournalEntry

Returns
JournalEntry JournalEntry
The most recent JournalEntry in back navigation history, if there is one.

Remarks
See NavigationService.RemoveBackEntry.
See AddBackEntry(CustomContentState)AddBackEntry(CustomContentState)
Also
NavigationWindow.SandboxExternalContent Navigation
Window.SandboxExternalContent
I n this Article
Gets or sets a value that indicates whether a NavigationWindow isolates external Extensible Application Markup
Language (XAML ) content within a partial trust security sandbox (with default Internet zone permission set).
public bool SandboxExternalContent { get; set; }
member this.SandboxExternalContent : bool with get, set

Returns
Boolean Boolean
true if content is isolated within a partial trust security sandbox; otherwise, false . The default is false .

Exceptions
SecurityException SecurityException
SandboxExternalContent is set when an application is executing in partial trust.

Remarks
External content is XAML content that is not included with an application as either a resource file or a content file (for
more information, see WPF Application Resource, Content, and Data Files).
When SandboxExternalContent is true, and the content of the NavigationWindow is an external XAML file, the content
is loaded into a partial trust security sandbox that is limited to the default Internet zone permission set. Additionally,
the external content is loaded into a separate process. Consequently, the external content becomes isolated and does
not have access to application-scope resources, such as resource dictionaries (for more information, see
ResourceDictionary).
Note

NavigationWindow contains external content only when the Source property is set to the uniform resource identifier
(URI) for an external XAML file. NavigationWindow content that is provided using the Content property is considered
internal content and, subsequently, is not isolated.
D ependency P roperty I nformation

Identifier field SandboxExternalContent

Metadata properties set to true None


NavigationWindow.SandboxExternalContentProperty
NavigationWindow.SandboxExternalContentProperty
I n this Article
Identifies the SandboxExternalContent dependency property.

public static readonly System.Windows.DependencyProperty SandboxExternalContentProperty;


staticval mutable SandboxExternalContentProperty : System.Windows.DependencyProperty

Returns
DependencyProperty DependencyProperty
NavigationWindow.ShouldSerializeContent Navigation
Window.ShouldSerializeContent
I n this Article
Indicates whether the Content property should be persisted.

public override bool ShouldSerializeContent ();


override this.ShouldSerializeContent : unit -> bool

Returns
Boolean Boolean
true if the property value has changed from its default; otherwise, false .

Remarks
This ShouldSerialize method is provided because the Content property does not have a simple default value. This
method indicates whether the property has changed from its default value. You typically call this method if you are
either developing a designer for the NavigationWindow or developing your own control incorporating the
NavigationWindow.
NavigationWindow.ShowsNavigationUI Navigation
Window.ShowsNavigationUI
I n this Article
Gets or sets a value that indicates whether a NavigationWindow shows its navigation UI.

public bool ShowsNavigationUI { get; set; }


member this.ShowsNavigationUI : bool with get, set

Returns
Boolean Boolean
true if the navigation UI is displayed; otherwise, false . The default is true .

Remarks
To aid backward and forward navigation, NavigationWindow automatically displays a navigation UI. The navigation UI
is displayed whether or not navigation has occurred.
D ependency P roperty I nformation

Identifier field ShowsNavigationUI

Metadata properties set to true None


NavigationWindow.ShowsNavigationUIProperty
NavigationWindow.ShowsNavigationUIProperty
I n this Article
Identifies the ShowsNavigationUI dependency property.

public static readonly System.Windows.DependencyProperty ShowsNavigationUIProperty;


staticval mutable ShowsNavigationUIProperty : System.Windows.DependencyProperty

Returns
DependencyProperty DependencyProperty
NavigationWindow.Source NavigationWindow.Source
I n this Article
Gets or sets the uniform resource identifier (URI) of the current content, or the URI of new content that is currently
being navigated to.

public Uri Source { get; set; }


member this.Source : Uri with get, set

Returns
Uri Uri
The URI for the current content, or the content that is currently being navigated to.

Examples
The following example shows how to navigate to a uniform resource identifier (URI) by setting the Source property.
// Navigate to URI using the Source property
this.Source = new Uri("HomePage.xaml", UriKind.Relative);

Remarks
See NavigationService.Source.
Note

Uniform resource identifiers (URIs) can be either relative or absolute. For more information, see Pack URIs in WPF.
D ependency P roperty I nformation

Identifier field Source

Metadata properties set to true Journal


NavigationWindow.SourceProperty NavigationWindow.
SourceProperty
I n this Article
Identifies the Source dependency property.

public static readonly System.Windows.DependencyProperty SourceProperty;


staticval mutable SourceProperty : System.Windows.DependencyProperty

Returns
DependencyProperty DependencyProperty
NavigationWindow.StopLoading NavigationWindow.
StopLoading
I n this Article
Stops further downloading of content for the current navigation request.

public void StopLoading ();


abstract member StopLoading : unit -> unit
override this.StopLoading : unit -> unit

Examples
The following example shows how to call the StopLoading method to stop navigation to content before it has finished
being downloaded.
void navigateStopButton_Click(object sender, RoutedEventArgs e)
{
this.StopLoading();
}

Remarks
StopLoading stops the download of the requested content, and causes the NavigationStopped event to be raised.
See NavigationService.StopLoading.
See NavigateNavigate
Also
PageFunction<T> PageFunction<T> Class
Represents a special type of page that allows you to treat navigation to a page in a similar fashion to calling a method.

D eclaration
public class PageFunction<T> : System.Windows.Navigation.PageFunctionBase
type PageFunction<'T> = class
inherit PageFunctionBase

I nheritance H ierarchy
Object Object
DispatcherObject DispatcherObject
DependencyObject DependencyObject
Visual Visual
UIElement UIElement
FrameworkElement FrameworkElement
Page Page
PageFunctionBase PageFunctionBase

Remarks
PageFunction<T> essentially allows you to treat a page navigation like a function call, in which a page navigates to
(calls) a page function.

To enable function call semantics, PageFunction<T> provides the following capabilities:


When the page function has finished processing, the page function code calls OnReturn to return to the calling page.
OnReturn accepts a ReturnEventArgs<T> parameter, which can be used to return a value by settings the Result
property. Otherwise, null can be passed to OnReturn to signify no value is returned
To detect when a page function has returned, the calling page can handle the Return event.
To return a value, the page function creates an instance of the ReturnEventArgs<T> class and sets the Result property
with the return value. The calling page can retrieve this value from the ReturnEventArgs<T> object that is passed to
the Return event handler.
By default, a PageFunction<T> is retained in navigation history after it returns. To ensure that it is not retained in
navigation history, its RemoveFromJournal property should be set to true .
See Structured Navigation Overview for details on how to use page functions.
See Navigation Topologies Overview for information on complex navigation structures that benefit from page
functions.
PageFunction<T> enables the development of wizards.

Constructors
PageFunction<T>()
PageFunction<T>()

Initializes a new instance of the PageFunction<T> class.


Methods
OnReturn(ReturnEventArgs<T>)
OnReturn(ReturnEventArgs<T>)

A PageFunction<T> calls OnReturn(ReturnEventArgs<T>) to return to the caller, passing a return value via a
ReturnEventArgs<T> object

Events
Return
Return

Occurs when a called PageFunction<T> returns, and can only be handled by the calling page.

See Also
Start() Start()
RemoveFromJournal RemoveFromJournal
PageFunction<T>.OnReturn PageFunction<T>.OnReturn
I n this Article
A PageFunction<T> calls OnReturn(ReturnEventArgs<T>) to return to the caller, passing a return value via a
ReturnEventArgs<T> object

protected virtual void OnReturn (System.Windows.Navigation.ReturnEventArgs<T> e);


abstract member OnReturn : System.Windows.Navigation.ReturnEventArgs<'T> -> unit
override this.OnReturn : System.Windows.Navigation.ReturnEventArgs<'T> -> unit

Parameters
e ReturnEventArgs<T> ReturnEventArgs<T>
A ReturnEventArgs<T> object that contains the PageFunction<T> return value (Result).

Examples
The following example shows how to call OnReturn.
void doneButton_Click(object sender, RoutedEventArgs e)
{
// Complete the page function and return data of type T
OnReturn(new ReturnEventArgs<String>(this.pageFunctionData.Text));
}

Remarks
OnReturn is called by a PageFunction<T> to initiate a navigation to the calling page.
This causes the Return event to be raised, in order for the calling page to:
Detect when the PageFunction<T> has returned.
Retrieve the return value from the PageFunction<T>.
See Start()Start()
Also RemoveFromJournalRemoveFromJournal
PageFunction<T>
I n this Article
Initializes a new instance of the PageFunction<T> class.
public PageFunction ();

Remarks
If a PageFunction<T> is not being kept alive (see KeepAlive), it needs to implement a default constructor to allow WPF
to create a new instance of it when navigated to in back or forward navigation history.
See PageFunctionBase
Also
PageFunction<T>.Return PageFunction<T>.Return
I n this Article
Occurs when a called PageFunction<T> returns, and can only be handled by the calling page.
public event System.Windows.Navigation.ReturnEventHandler<T> Return;
member this.Return : System.Windows.Navigation.ReturnEventHandler<'T>

Examples
The following example shows how to handle the Return event.

void callPageFunctionButton_Click(object sender, RoutedEventArgs e)


{
// Create page function object
GetStringPageFunction pageFunction = new GetStringPageFunction();

// Detect when page function returns


pageFunction.Return += new ReturnEventHandler<String>(PageFunction_Return);

// Call page function


this.NavigationService.Navigate(pageFunction);
}

void PageFunction_Return(object sender, ReturnEventArgs<String> e)


{
// Retrieve page function return value
string returnValue = e.Result;
}

Remarks
A calling page detects when a called PageFunction<T> returns by handling Return. Additionally, the calling page can
retrieve the PageFunction<T> return value from the Result property of the ReturnEventArgs<T> which is passed to
the event handler.
X A ML Attribute Usage
<object Return="ReturnEventHandler"/>

See Start()Start()
Also RemoveFromJournalRemoveFromJournal
PageFunctionBase PageFunctionBase Class
An abstract base class that is the parent of all page function classes.

D eclaration
public abstract class PageFunctionBase : System.Windows.Controls.Page
type PageFunctionBase = class
inherit Page

I nheritance H ierarchy
Object Object
DispatcherObject DispatcherObject
DependencyObject DependencyObject
Visual Visual
UIElement UIElement
FrameworkElement FrameworkElement
Page Page

Remarks
PageFunction<T> derives from PageFunctionBase.

Constructors
PageFunctionBase()
PageFunctionBase()

Initializes a new instance of the PageFunctionBase type.

Properties
RemoveFromJournal
RemoveFromJournal

Gets or sets a value that indicates whether the page function should not be added to navigation history.

Methods
Start()
Start()

Override this method to initialize a PageFunction<T> when it is navigated to for the first time.
PageFunctionBase
I n this Article
Initializes a new instance of the PageFunctionBase type.
protected PageFunctionBase ();
PageFunctionBase.RemoveFromJournal PageFunction
Base.RemoveFromJournal
I n this Article
Gets or sets a value that indicates whether the page function should not be added to navigation history.

public bool RemoveFromJournal { get; set; }


member this.RemoveFromJournal : bool with get, set

Returns
Boolean Boolean
A Boolean that indicates whether a page function should not be added to navigation history. The default value is false
.

Remarks
OnReturn must be called for RemoveFromJournal to be applied.
PageFunctionBase.Start PageFunctionBase.Start
I n this Article
Override this method to initialize a PageFunction<T> when it is navigated to for the first time.
protected virtual void Start ();
abstract member Start : unit -> unit
override this.Start : unit -> unit

Remarks
This method is only called on the initial navigation. It is not called if a PageFunction<T> is later reactivated.
RequestNavigateEventArgs RequestNavigateEventArgs
Class
Provides data for the RequestNavigate event.

D eclaration
public class RequestNavigateEventArgs : System.Windows.RoutedEventArgs
type RequestNavigateEventArgs = class
inherit RoutedEventArgs

I nheritance H ierarchy
Object Object
EventArgs EventArgs
RoutedEventArgs RoutedEventArgs

Remarks
This event is raised by Hyperlink when clicked. The event is processed by the navigator (NavigationWindow or Frame)
whose content contains the Hyperlink.

Constructors
RequestNavigateEventArgs()
RequestNavigateEventArgs()

Initializes a new instance of the RequestNavigateEventArgs class. This constructor is protected.

RequestNavigateEventArgs(Uri, String)
RequestNavigateEventArgs(Uri, String)

Initializes a new instance of the RequestNavigateEventArgs class with a uniform resource identifier (URI) and
target name.

Properties
Target
Target

The navigator that will host the content that is navigated to.

Uri
Uri

The uniform resource identifier (URI) for the content that is being navigated to.

Methods
InvokeEventHandler(Delegate, Object)
InvokeEventHandler(Delegate, Object)

Invokes a specified event handler from a specified sender.


RequestNavigateEventArgs.InvokeEventHandler Request
NavigateEventArgs.InvokeEventHandler
I n this Article
Invokes a specified event handler from a specified sender.

protected override void InvokeEventHandler (Delegate genericHandler, object genericTarget);


override this.InvokeEventHandler : Delegate * obj -> unit

Parameters
genericHandler Delegate Delegate
The name of the handler.
genericTarget Object Object
The object that is raising the event.
RequestNavigateEventArgs RequestNavigateEventArgs
I n this Article

Overloads
RequestNavigateEventArgs()
Initializes a new instance of the RequestNavigateEventArgs
class. This constructor is protected.

RequestNavigateEventArgs(Uri, String) RequestNavigateEvent


Args(Uri, String) Initializes a new instance of the RequestNavigateEventArgs
class with a uniform resource identifier (URI) and target name.

RequestNavigateEventArgs()
Initializes a new instance of the RequestNavigateEventArgs class. This constructor is protected.
protected RequestNavigateEventArgs ();

RequestNavigateEventArgs(Uri, String)
RequestNavigateEventArgs(Uri, String)
Initializes a new instance of the RequestNavigateEventArgs class with a uniform resource identifier (URI) and target
name.
public RequestNavigateEventArgs (Uri uri, string target);
new System.Windows.Navigation.RequestNavigateEventArgs : Uri * string ->
System.Windows.Navigation.RequestNavigateEventArgs

Parameters
uri Uri Uri
The target URI.
target String String
The target name.
RequestNavigateEventArgs.Target RequestNavigateEvent
Args.Target
I n this Article
The navigator that will host the content that is navigated to.

public string Target { get; }


member this.Target : string

Returns
String String
The navigator (NavigationWindow or Frame) that will host the content that is navigated to.
RequestNavigateEventArgs.Uri RequestNavigateEvent
Args.Uri
I n this Article
The uniform resource identifier (URI) for the content that is being navigated to.

public Uri Uri { get; }


member this.Uri : Uri

Returns
Uri Uri
The URI for the content that is being navigated to.
RequestNavigateEventHandler RequestNavigateEvent
Handler Delegate
Represents the method that will handle the RequestNavigate routed event of the Hyperlink class.

D eclaration
public delegate void RequestNavigateEventHandler(object sender, RequestNavigateEventArgs e);
type RequestNavigateEventHandler = delegate of obj * RequestNavigateEventArgs -> unit

I nheritance H ierarchy
Object Object
Delegate Delegate
ReturnEventArgs<T> ReturnEventArgs<T> Class
Provides data for the Return event.

D eclaration
public class ReturnEventArgs<T> : EventArgs
type ReturnEventArgs<'T> = class
inherit EventArgs

I nheritance H ierarchy
Object Object
EventArgs EventArgs

Constructors
ReturnEventArgs<T>()
ReturnEventArgs<T>()

Initializes a new instance of the ReturnEventArgs<T> class.

ReturnEventArgs<T>(T)
ReturnEventArgs<T>(T)

Initializes a new instance of the ReturnEventArgs<T> class with the return value.

Properties
Result
Result

Gets or sets the value that is returned by the page function.


ReturnEventArgs<T>.Result ReturnEventArgs<T>.Result
I n this Article
Gets or sets the value that is returned by the page function.
public T Result { get; set; }
member this.Result : 'T with get, set

Returns
TT
The value that is returned by the page function.
ReturnEventArgs<T> ReturnEventArgs<T>
I n this Article

Overloads
ReturnEventArgs<T>()
Initializes a new instance of the ReturnEventArgs<T> class.

ReturnEventArgs<T>(T) ReturnEventArgs<T>(T)
Initializes a new instance of the ReturnEventArgs<T> class
with the return value.

ReturnEventArgs<T>()
Initializes a new instance of the ReturnEventArgs<T> class.
public ReturnEventArgs ();

ReturnEventArgs<T>(T) ReturnEventArgs<T>(T)
Initializes a new instance of the ReturnEventArgs<T> class with the return value.
public ReturnEventArgs (T result);
new System.Windows.Navigation.ReturnEventArgs<'T> : 'T ->
System.Windows.Navigation.ReturnEventArgs<'T>

Parameters
result TT
The value to be returned.
ReturnEventHandler<T> ReturnEventHandler<T>
Delegate
Represents the method that will handle the Return event of the PageFunction<T> class.

D eclaration
public delegate void ReturnEventHandler<T>(object sender, ReturnEventArgs<T> e);
type ReturnEventHandler<'T> = delegate of obj * ReturnEventArgs<'T> -> unit

I nheritance H ierarchy
Object Object
Delegate Delegate

Das könnte Ihnen auch gefallen