Frame.NavigationService Property

Definition

Gets the NavigationService that is used by this Frame to provide navigation services.

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

Property Value

A Frame object that represents the NavigationService used by this Frame, if one is available. Otherwise, null is returned.

Remarks

Frame uses NavigationService to support navigation for hosted content. NavigationService is useful for code that hosts a Frame to get a reference to the NavigationService. Content that is hosted by a Frame, such as Page, should use GetNavigationService or NavigationService to get a reference to the NavigationService.

Note

NavigationService does not return a reference to the same NavigationService as calling GetNavigationService and passing Frame does. The former returns the NavigationService that is owned by the Frame while the latter returns the NavigationService for the navigation host that navigated to the content in which the Frame is hosted. The following code demonstrates the differences.

C#
using System.Windows.Controls;
using System.Windows.Navigation;
C#
// 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);

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10