This topic has not yet been rated - Rate this topic

Page.NavigationService Property

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Gets the navigation service that the host of the page is using to manage navigation.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
'Declaration
Public ReadOnly Property NavigationService As NavigationService

Property Value

Type: System.Windows.Navigation.NavigationService
The NavigationService object that the host of the page is using to manage navigation, or Nothing if the host does not support navigation.

Pages can be hosted by multiple types of hosts, including Window, NavigationWindow, Frame, and a browser.

Pages often need to integrate with their host's navigation to provide in-page navigation support. However, because a page may not know what its host will be at run time, it cannot integrate directly with its host's navigation members to do so.

Instead, it can attempt to use a navigation service, which is a service that supports browser-style navigation and is encapsulated by the NavigationService class. You cannot create your own NavigationService instance, though. Instead, host types such as NavigationWindow, Frame, or a browser create their own NavigationService instance that you can access from the NavigationService property.

The navigation service that is returned from the NavigationService property is the instance of the NavigationService class that is managed by the first navigator up the visual tree. If one is not found, Nothing is returned, indicating a page's host does not support navigation.

NoteNote

The Window class does not support navigation and does not provide a navigation service.

The following example shows how a page can check if a navigation service is available and, if so, use it to navigate back to the previous page.


Partial Public Class HomePage
    Inherits Page
    Public Sub New()
        InitializeComponent()

        ' Don't allow back navigation if no navigation service
        If Me.NavigationService IsNot Nothing Then
            Me.goBackButton.IsEnabled = False
        End If
    End Sub

    Private Sub goBackButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
        ' Go to previous entry in journal back stack
        If Me.NavigationService.CanGoBack Then
            Me.NavigationService.GoBack()
        End If
    End Sub
End Class


.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8 Consumer Preview, Windows Server 8 Beta, Windows 7, Windows Server 2008 SP2, Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.