共用方式為


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 參考。 前者會傳回 NavigationServiceFrame 擁有的 ,而後者會傳回 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)

適用於