Frame.NavigationService 属性

定义

获取此 NavigationService 用来提供导航服务的 Frame

public:
 property System::Windows::Navigation::NavigationService ^ NavigationService { System::Windows::Navigation::NavigationService ^ get(); };
public System.Windows.Navigation.NavigationService NavigationService { get; }
member this.NavigationService : System.Windows.Navigation.NavigationService
Public ReadOnly Property NavigationService As NavigationService

属性值

一个 Frame 对象,它表示此 NavigationService 使用的 Frame(如果有)。 否则将返回 null

注解

Frame 使用 NavigationService 来支持托管内容的导航。 NavigationService 对于承载 Frame 以获取对 的 NavigationService引用的代码很有用。 托管 Frame的内容(如 Page)应使用 GetNavigationServiceNavigationService 来获取对 的 NavigationService引用。

注意

NavigationService不返回与调用 GetNavigationService 和传递 Frame 相同的NavigationService对 的引用。 前者返回 NavigationService 拥有的 Frame ,而后者 NavigationService 返回导航主机的 ,该导航主机导航到在其中托管 的内容 Frame 。 以下代码演示了差异。

using System.Windows.Controls;
using System.Windows.Navigation;
Imports System.Windows.Controls
Imports System.Windows.Navigation
// Get the NavigationService owned by the Frame
NavigationService frameNS = this.frame.NavigationService;

// Get the NavigationService for the navigation host that navigated
// to the content in which the Frame is hosted
NavigationService navigationHostNS = NavigationService.GetNavigationService(this.frame);
' Get the NavigationService owned by the Frame
Dim frameNS As NavigationService = Me.frame.NavigationService

' Get the NavigationService for the navigation host that navigated
' to the content in which the Frame is hosted
Dim navigationHostNS As NavigationService = NavigationService.GetNavigationService(Me.frame)

适用于