Table of Contents

Class NavigationView

Namespace
Wpf.Ui.Controls
Assembly
Wpf.Ui.dll

Represents a container that enables navigation of app content. It has a header, a view for the main content, and a menu pane for navigation commands.

[TemplatePart(Name = "PART_NavigationViewContentPresenter", Type = typeof(NavigationViewContentPresenter))]
[TemplatePart(Name = "PART_MenuItemsItemsControl", Type = typeof(ItemsControl))]
[TemplatePart(Name = "PART_FooterMenuItemsItemsControl", Type = typeof(ItemsControl))]
[TemplatePart(Name = "PART_BackButton", Type = typeof(Button))]
[TemplatePart(Name = "PART_ToggleButton", Type = typeof(Button))]
[TemplatePart(Name = "PART_AutoSuggestBoxSymbolButton", Type = typeof(Button))]
public class NavigationView : Control, IAnimatable, IFrameworkInputElement, IInputElement, ISupportInitialize, IQueryAmbient, INavigationView
Inheritance
NavigationView
Implements
Inherited Members

Constructors

NavigationView()

Initializes a new instance of the NavigationView class.

public NavigationView()

Fields

AlwaysShowHeaderProperty

Identifies the AlwaysShowHeader dependency property.

public static readonly DependencyProperty AlwaysShowHeaderProperty

Field Value

DependencyProperty

AutoSuggestBoxProperty

Identifies the AutoSuggestBox dependency property.

public static readonly DependencyProperty AutoSuggestBoxProperty

Field Value

DependencyProperty

BackRequestedEvent

Identifies the BackRequested routed event.

public static readonly RoutedEvent BackRequestedEvent

Field Value

RoutedEvent

BreadcrumbBarProperty

Identifies the BreadcrumbBar dependency property.

public static readonly DependencyProperty BreadcrumbBarProperty

Field Value

DependencyProperty

CompactPaneLengthProperty

Identifies the CompactPaneLength dependency property.

public static readonly DependencyProperty CompactPaneLengthProperty

Field Value

DependencyProperty

ContentOverlayProperty

Identifies the ContentOverlay dependency property.

public static readonly DependencyProperty ContentOverlayProperty

Field Value

DependencyProperty

EnableDebugMessagesProperty

Identifies the EnableDebugMessages dependency property.

public static readonly DependencyProperty EnableDebugMessagesProperty

Field Value

DependencyProperty

FooterMenuItemsProperty

Identifies the FooterMenuItems dependency property.

public static readonly DependencyProperty FooterMenuItemsProperty

Field Value

DependencyProperty

FooterMenuItemsSourceProperty

Identifies the FooterMenuItemsSource dependency property.

public static readonly DependencyProperty FooterMenuItemsSourceProperty

Field Value

DependencyProperty

FrameMarginProperty

Identifies the FrameMargin dependency property.

public static readonly DependencyProperty FrameMarginProperty

Field Value

DependencyProperty

HeaderContentProperty

Registers attached property NavigationView.HeaderContent

public static readonly DependencyProperty HeaderContentProperty

Field Value

DependencyProperty

HeaderProperty

Identifies the Header dependency property.

public static readonly DependencyProperty HeaderProperty

Field Value

DependencyProperty

HeaderVisibilityProperty

Identifies the HeaderVisibility dependency property.

public static readonly DependencyProperty HeaderVisibilityProperty

Field Value

DependencyProperty

IsBackButtonVisibleProperty

Identifies the IsBackButtonVisible dependency property.

public static readonly DependencyProperty IsBackButtonVisibleProperty

Field Value

DependencyProperty

IsBackEnabledProperty

Identifies the IsBackEnabled dependency property.

public static readonly DependencyProperty IsBackEnabledProperty

Field Value

DependencyProperty

IsPaneOpenProperty

Identifies the IsPaneOpen dependency property.

public static readonly DependencyProperty IsPaneOpenProperty

Field Value

DependencyProperty

IsPaneToggleVisibleProperty

Identifies the IsPaneToggleVisible dependency property.

public static readonly DependencyProperty IsPaneToggleVisibleProperty

Field Value

DependencyProperty

IsPaneVisibleProperty

Identifies the IsPaneVisible dependency property.

public static readonly DependencyProperty IsPaneVisibleProperty

Field Value

DependencyProperty

ItemInvokedEvent

Identifies the ItemInvoked routed event.

public static readonly RoutedEvent ItemInvokedEvent

Field Value

RoutedEvent

ItemTemplateProperty

Identifies the ItemTemplate dependency property.

public static readonly DependencyProperty ItemTemplateProperty

Field Value

DependencyProperty

MenuItemsProperty

Identifies the MenuItems dependency property.

public static readonly DependencyProperty MenuItemsProperty

Field Value

DependencyProperty

MenuItemsSourceProperty

Identifies the MenuItemsSource dependency property.

public static readonly DependencyProperty MenuItemsSourceProperty

Field Value

DependencyProperty

NavigatedEvent

Identifies the Navigated routed event.

public static readonly RoutedEvent NavigatedEvent

Field Value

RoutedEvent

NavigatingEvent

Identifies the Navigating routed event.

public static readonly RoutedEvent NavigatingEvent

Field Value

RoutedEvent

OpenPaneLengthProperty

Identifies the OpenPaneLength dependency property.

public static readonly DependencyProperty OpenPaneLengthProperty

Field Value

DependencyProperty

PaneClosedEvent

Identifies the PaneClosed routed event.

public static readonly RoutedEvent PaneClosedEvent

Field Value

RoutedEvent

PaneDisplayModeProperty

Identifies the PaneDisplayMode dependency property.

public static readonly DependencyProperty PaneDisplayModeProperty

Field Value

DependencyProperty

PaneFooterProperty

Identifies the PaneFooter dependency property.

public static readonly DependencyProperty PaneFooterProperty

Field Value

DependencyProperty

PaneHeaderProperty

Identifies the PaneHeader dependency property.

public static readonly DependencyProperty PaneHeaderProperty

Field Value

DependencyProperty

PaneOpenedEvent

Identifies the PaneOpened routed event.

public static readonly RoutedEvent PaneOpenedEvent

Field Value

RoutedEvent

PaneTitleProperty

Identifies the PaneTitle dependency property.

public static readonly DependencyProperty PaneTitleProperty

Field Value

DependencyProperty

SelectionChangedEvent

Identifies the SelectionChanged routed event.

public static readonly RoutedEvent SelectionChangedEvent

Field Value

RoutedEvent

TitleBarProperty

Identifies the TitleBar dependency property.

public static readonly DependencyProperty TitleBarProperty

Field Value

DependencyProperty

TransitionDurationProperty

Identifies the TransitionDuration dependency property.

public static readonly DependencyProperty TransitionDurationProperty

Field Value

DependencyProperty

TransitionProperty

Identifies the Transition dependency property.

public static readonly DependencyProperty TransitionProperty

Field Value

DependencyProperty

Properties

AlwaysShowHeader

Gets or sets a value indicating whether the header is always visible.

public bool AlwaysShowHeader { get; set; }

Property Value

bool

AutoSuggestBox

Gets or sets an AutoSuggestBox to be displayed in the NavigationView.

public AutoSuggestBox? AutoSuggestBox { get; set; }

Property Value

AutoSuggestBox

AutoSuggestBoxSymbolButton

Gets or sets the control that is visitable if PaneDisplayMode="Left" and in compact state

protected Button? AutoSuggestBoxSymbolButton { get; set; }

Property Value

Button

BackButton

Gets or sets the control located at the top of the pane with left arrow icon.

protected Button? BackButton { get; set; }

Property Value

Button

BreadcrumbBar

Gets or sets an BreadcrumbBar that is in Header.

public BreadcrumbBar? BreadcrumbBar { get; set; }

Property Value

BreadcrumbBar

CanGoBack

Gets a value indicating whether there is at least one entry in back navigation history.

public bool CanGoBack { get; }

Property Value

bool

CompactPaneLength

Gets or sets the width of the NavigationView pane in its compact display mode.

public double CompactPaneLength { get; set; }

Property Value

double

ContentOverlay

Gets or sets a UI element that is shown at the top of the control, below the pane if PaneDisplayMode is Top.

public object? ContentOverlay { get; set; }

Property Value

object

EnableDebugMessages

Gets or sets a value indicating whether debugging messages for this control are enabled

public bool EnableDebugMessages { get; set; }

Property Value

bool

FooterMenuItems

Gets the list of objects to be used as navigation items in the footer menu.

public IList FooterMenuItems { get; }

Property Value

IList

FooterMenuItemsItemsControl

Gets or sets the control located at the top of the pane with hamburger icon.

protected ItemsControl FooterMenuItemsItemsControl { get; set; }

Property Value

ItemsControl

FooterMenuItemsSource

Gets or sets the object that represents the navigation items to be used in the footer menu.

[Bindable(true)]
public object? FooterMenuItemsSource { get; set; }

Property Value

object

FrameMargin

Gets or sets margin for a Frame of INavigationView

public Thickness FrameMargin { get; set; }

Property Value

Thickness

Header

Gets or sets the header content.

public object? Header { get; set; }

Property Value

object

HeaderVisibility

Gets or sets the Header visibility.

public Visibility HeaderVisibility { get; set; }

Property Value

Visibility

IsBackButtonVisible

Gets or sets a value that indicates whether the back button is visible or not. Default value is "Auto", which indicates that button visibility depends on the DisplayMode setting of the NavigationView.

public NavigationViewBackButtonVisible IsBackButtonVisible { get; set; }

Property Value

NavigationViewBackButtonVisible

IsBackEnabled

Gets a value indicating whether the back button is enabled or disabled.

public bool IsBackEnabled { get; protected set; }

Property Value

bool

IsPaneOpen

Gets or sets a value indicating whether the NavigationView pane is expanded to its full width.

public bool IsPaneOpen { get; set; }

Property Value

bool

IsPaneToggleVisible

Gets or sets a value indicating whether the toggle button is visible.

public bool IsPaneToggleVisible { get; set; }

Property Value

bool

IsPaneVisible

Gets or sets a value indicating whether the pane is shown.

public bool IsPaneVisible { get; set; }

Property Value

bool

ItemTemplate

Gets or sets the template property for MenuItems and FooterMenuItems.

public ControlTemplate? ItemTemplate { get; set; }

Property Value

ControlTemplate

Journal

protected List<string> Journal { get; }

Property Value

List<string>

MenuItems

Gets the collection of menu items displayed in the NavigationView.

public IList MenuItems { get; }

Property Value

IList

MenuItemsItemsControl

Gets or sets the control located at the top of the pane with left arrow icon.

protected ItemsControl MenuItemsItemsControl { get; set; }

Property Value

ItemsControl

MenuItemsSource

Gets or sets an object source used to generate the content of the NavigationView menu.

[Bindable(true)]
public object? MenuItemsSource { get; set; }

Property Value

object

NavigationStack

protected ObservableCollection<INavigationViewItem> NavigationStack { get; }

Property Value

ObservableCollection<INavigationViewItem>

NavigationViewContentPresenter

Gets or sets the control responsible for rendering the content.

protected NavigationViewContentPresenter NavigationViewContentPresenter { get; set; }

Property Value

NavigationViewContentPresenter

OpenPaneLength

Gets or sets the width of the NavigationView pane when it's fully expanded.

public double OpenPaneLength { get; set; }

Property Value

double

PageIdOrTargetTagNavigationViewsDictionary

protected Dictionary<string, INavigationViewItem> PageIdOrTargetTagNavigationViewsDictionary { get; }

Property Value

Dictionary<string, INavigationViewItem>

PageTypeNavigationViewsDictionary

protected Dictionary<Type, INavigationViewItem> PageTypeNavigationViewsDictionary { get; }

Property Value

Dictionary<Type, INavigationViewItem>

PaneDisplayMode

Gets or sets a value that specifies how the pane and content areas of a NavigationView are being shown.

It is not the same PaneDisplayMode as in WinUi.

public NavigationViewPaneDisplayMode PaneDisplayMode { get; set; }

Property Value

NavigationViewPaneDisplayMode

PaneFooter

Gets or sets the content for the pane footer.

public object? PaneFooter { get; set; }

Property Value

object

PaneHeader

Gets or sets the content for the pane header.

public object? PaneHeader { get; set; }

Property Value

object

PaneTitle

Gets or sets the label adjacent to the menu icon when the NavigationView pane is open.

public string? PaneTitle { get; set; }

Property Value

string

SelectedItem

Gets the selected item.

public INavigationViewItem? SelectedItem { get; protected set; }

Property Value

INavigationViewItem

TitleBar

Gets or sets an TitleBar to be displayed in the NavigationView.

public TitleBar? TitleBar { get; set; }

Property Value

TitleBar

ToggleButton

Gets or sets the control located at the top of the pane with hamburger icon.

protected Button? ToggleButton { get; set; }

Property Value

Button

Transition

Gets or sets type of INavigationView transitions during navigation.

public Transition Transition { get; set; }

Property Value

Transition

TransitionDuration

Gets or sets a value deciding how long the effect of the transition between the pages should take.

[Bindable(true)]
public int TransitionDuration { get; set; }

Property Value

int

Methods

AddItemsToAutoSuggestBoxItems()

protected virtual void AddItemsToAutoSuggestBoxItems()

AddItemsToAutoSuggestBoxItems(IEnumerable)

protected virtual void AddItemsToAutoSuggestBoxItems(IEnumerable list)

Parameters

list IEnumerable

AddItemsToDictionaries()

protected virtual void AddItemsToDictionaries()

AddItemsToDictionaries(IEnumerable)

protected virtual void AddItemsToDictionaries(IEnumerable list)

Parameters

list IEnumerable

AutoSuggestBoxSymbolButtonOnClick(object, RoutedEventArgs)

This virtual method is called when AutoSuggestBoxSymbolButton is clicked.

protected virtual void AutoSuggestBoxSymbolButtonOnClick(object sender, RoutedEventArgs e)

Parameters

sender object
e RoutedEventArgs

BreadcrumbBarOnItemClicked(BreadcrumbBar, BreadcrumbBarItemClickedEventArgs)

protected virtual void BreadcrumbBarOnItemClicked(BreadcrumbBar sender, BreadcrumbBarItemClickedEventArgs e)

Parameters

sender BreadcrumbBar
e BreadcrumbBarItemClickedEventArgs

ClearJournal()

Clears the NavigationView history.

public virtual void ClearJournal()

CloseNavigationViewItemMenus()

protected virtual void CloseNavigationViewItemMenus()

DeactivateMenuItems(IEnumerable)

protected void DeactivateMenuItems(IEnumerable list)

Parameters

list IEnumerable

GetHeaderContent(FrameworkElement)

Helper for getting HeaderContentProperty from target.

[AttachedPropertyBrowsableForType(typeof(FrameworkElement))]
public static object? GetHeaderContent(FrameworkElement target)

Parameters

target FrameworkElement

FrameworkElement to read HeaderContentProperty from.

Returns

object

HeaderContent property value.

GetTemplateChild<T>(string)

protected T GetTemplateChild<T>(string name) where T : DependencyObject

Parameters

name string

Returns

T

Type Parameters

T

GoBack()

Navigates the NavigationView to the previous journal entry.

public virtual bool GoBack()

Returns

bool

true if successfully navigated backward, otherwise false.

GoForward()

Navigates the NavigationView to the next journal entry.

public virtual bool GoForward()

Returns

bool

true if successfully navigated forward, otherwise false.

Navigate(string, object?)

Synchronously navigates current navigation Frame to the given Element.

public virtual bool Navigate(string pageIdOrTargetTag, object? dataContext = null)

Parameters

pageIdOrTargetTag string
dataContext object

Returns

bool

Navigate(Type, object?)

Synchronously navigates current navigation Frame to the given Element.

public virtual bool Navigate(Type pageType, object? dataContext = null)

Parameters

pageType Type
dataContext object

Returns

bool

NavigateToMenuItemFromAutoSuggestBox(IEnumerable, string)

protected virtual bool NavigateToMenuItemFromAutoSuggestBox(IEnumerable list, string selectedSuggestBoxItem)

Parameters

list IEnumerable
selectedSuggestBoxItem string

Returns

bool

NavigateWithHierarchy(Type, object?)

Synchronously adds an element to the navigation stack and navigates current navigation Frame to the

public virtual bool NavigateWithHierarchy(Type pageType, object? dataContext = null)

Parameters

pageType Type
dataContext object

Returns

bool

OnApplyTemplate()

When overridden in a derived class, is invoked whenever application code or internal processes call ApplyTemplate().

public override void OnApplyTemplate()

OnBackButtonClick(object, RoutedEventArgs)

This virtual method is called when BackButton is clicked.

protected virtual void OnBackButtonClick(object sender, RoutedEventArgs e)

Parameters

sender object
e RoutedEventArgs

OnBackRequested()

Raises the back requested event.

protected virtual void OnBackRequested()

OnInitialized(EventArgs)

Raises the Initialized event. This method is invoked whenever IsInitialized is set to true internally.

protected override void OnInitialized(EventArgs e)

Parameters

e EventArgs

The RoutedEventArgs that contains the event data.

OnItemInvoked()

Raises the item invoked event.

protected virtual void OnItemInvoked()

OnItemTemplateChanged()

This virtual method is called when ItemTemplate is changed.

protected virtual void OnItemTemplateChanged()

OnMouseDown(MouseButtonEventArgs)

Invoked when an unhandled System.Windows.Input.Mouse.MouseDown attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.

protected override void OnMouseDown(MouseButtonEventArgs e)

Parameters

e MouseButtonEventArgs

The MouseButtonEventArgs that contains the event data. This event data reports details about the mouse button that was pressed and the handled state.

OnNavigated(object)

Raises the navigated requested event.

protected virtual void OnNavigated(object page)

Parameters

page object

OnNavigating(object)

Raises the navigating requested event.

protected virtual bool OnNavigating(object sourcePage)

Parameters

sourcePage object

Returns

bool

OnPaneClosed()

Raises the pane closed event.

protected virtual void OnPaneClosed()

OnPaneDisplayModeChanged()

This virtual method is called when PaneDisplayMode is changed.

protected virtual void OnPaneDisplayModeChanged()

OnPaneOpened()

Raises the pane opened event.

protected virtual void OnPaneOpened()

OnSelectionChanged()

Raises the selection changed event.

protected virtual void OnSelectionChanged()

OnSizeChanged(object, SizeChangedEventArgs)

This virtual method is called when ActualWidth or ActualHeight (or both) changed.

protected virtual void OnSizeChanged(object sender, SizeChangedEventArgs e)

Parameters

sender object
e SizeChangedEventArgs

OnToggleButtonClick(object, RoutedEventArgs)

This virtual method is called when ToggleButton is clicked.

protected virtual void OnToggleButtonClick(object sender, RoutedEventArgs e)

Parameters

sender object
e RoutedEventArgs

OnUnloaded(object, RoutedEventArgs)

This virtual method is called when this element is detached form a loaded tree.

protected virtual void OnUnloaded(object sender, RoutedEventArgs e)

Parameters

sender object
e RoutedEventArgs

ReplaceContent(Type?)

Replaces the contents of the navigation frame, without changing the currently selected item or triggering an SelectionChanged.

public virtual bool ReplaceContent(Type? pageTypeToEmbed)

Parameters

pageTypeToEmbed Type

Returns

bool

ReplaceContent(UIElement, object?)

Replaces the contents of the navigation frame, without changing the currently selected item or triggering an SelectionChanged.

public virtual bool ReplaceContent(UIElement pageInstanceToEmbed, object? dataContext = null)

Parameters

pageInstanceToEmbed UIElement
dataContext object

Returns

bool

SetHeaderContent(FrameworkElement, object?)

Helper for setting HeaderContentProperty on target.

public static void SetHeaderContent(FrameworkElement target, object? headerContent)

Parameters

target FrameworkElement

FrameworkElement to set HeaderContentProperty on.

headerContent object

HeaderContent property value.

SetPageProviderService(INavigationViewPageProvider)

Allows you to assign to the NavigationView a special service responsible for retrieving the page instances.

public void SetPageProviderService(INavigationViewPageProvider navigationViewPageProvider)

Parameters

navigationViewPageProvider INavigationViewPageProvider

SetServiceProvider(IServiceProvider)

Allows you to assign a general IServiceProvider to the NavigationView that will be used to retrieve page instances and view models.

public void SetServiceProvider(IServiceProvider serviceProvider)

Parameters

serviceProvider IServiceProvider

UpdateMenuItemsTemplate()

protected virtual void UpdateMenuItemsTemplate()

UpdateMenuItemsTemplate(IEnumerable)

protected virtual void UpdateMenuItemsTemplate(IEnumerable list)

Parameters

list IEnumerable

UpdateVisualState(NavigationView)

protected static void UpdateVisualState(NavigationView navigationView)

Parameters

navigationView NavigationView

Events

BackRequested

Occurs when the back button receives an interaction such as a click or tap.

public event TypedEventHandler<NavigationView, RoutedEventArgs> BackRequested

Event Type

TypedEventHandler<NavigationView, RoutedEventArgs>

ItemInvoked

Occurs when an item in the menu receives an interaction such as a click or tap.

public event TypedEventHandler<NavigationView, RoutedEventArgs> ItemInvoked

Event Type

TypedEventHandler<NavigationView, RoutedEventArgs>

Navigated

Occurs when navigated to page

public event TypedEventHandler<NavigationView, NavigatedEventArgs> Navigated

Event Type

TypedEventHandler<NavigationView, NavigatedEventArgs>

Navigating

Occurs when a new navigation is requested

public event TypedEventHandler<NavigationView, NavigatingCancelEventArgs> Navigating

Event Type

TypedEventHandler<NavigationView, NavigatingCancelEventArgs>

PaneClosed

Occurs when the NavigationView pane is closed.

public event TypedEventHandler<NavigationView, RoutedEventArgs> PaneClosed

Event Type

TypedEventHandler<NavigationView, RoutedEventArgs>

PaneOpened

Occurs when the NavigationView pane is opened.

public event TypedEventHandler<NavigationView, RoutedEventArgs> PaneOpened

Event Type

TypedEventHandler<NavigationView, RoutedEventArgs>

SelectionChanged

Occurs when the currently selected item changes.

public event TypedEventHandler<NavigationView, RoutedEventArgs> SelectionChanged

Event Type

TypedEventHandler<NavigationView, RoutedEventArgs>