語言

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對於承載 a Frame 的程式碼來說非常有用,可以取得 。NavigationService 由 Frame所託管的內容,例如 Page,應使用 GetNavigationService 或 NavigationService 取得對 NavigationService的參考。

Note

NavigationService不會回傳與呼叫NavigationService與傳遞GetNavigationService相同的Frame參考。 前者回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)

適用於