public class NavigationHost : ContentControl Presents the current entry of a navigation region.
Remarks
Each entry gets a new ContentPresenter and a new view, also when two entries have the same type or the same borrowed content, so no view state leaks from one entry to the next. A retained entry gets a new view when it becomes current again: keep state that must survive in the ViewModel.
The view comes from NavigationHost.ViewLocator, then from an INavigationViewLocator registered in the navigator's services, then from the implicit DataTemplate keyed by the content type or a base type. The host follows the region while it is loaded, and never changes entries when it is unloaded. NavigationCommands.BrowseBack goes back when the region can go back and isn't transitioning.
The host sets its own ContentControl.Content: don't set Content, ContentTemplate or ContentTemplateSelector on it. Present entries with implicit DataTemplates or a locator.
Constructors
NavigationHost
public NavigationHost() Creates a host.
Fields
EmptyContentProperty
public static readonly DependencyProperty EmptyContentProperty Identifies the NavigationHost.EmptyContent dependency property.
HandlesBrowseBackProperty
public static readonly DependencyProperty HandlesBrowseBackProperty Identifies the NavigationHost.HandlesBrowseBack dependency property.
IsTransitioningProperty
public static readonly DependencyProperty IsTransitioningProperty Identifies the NavigationHost.IsTransitioning dependency property.
RegionProperty
public static readonly DependencyProperty RegionProperty Identifies the NavigationHost.Region dependency property.
ViewLocatorProperty
public static readonly DependencyProperty ViewLocatorProperty Identifies the NavigationHost.ViewLocator dependency property.
Properties
EmptyContent
public object? EmptyContent { get; set; } Gets or sets the content shown while the region is empty or no region is set.
HandlesBrowseBack
public bool HandlesBrowseBack { get; set; } Gets or sets whether NavigationCommands.BrowseBack goes back in the region. The default is true.
IsTransitioning
public bool IsTransitioning { get; } Gets whether the region has a transition in flight.
ViewLocator
public INavigationViewLocator? ViewLocator { get; set; } Gets or sets the locator asked first for each entry's view.