Class NavigationView
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
AutoSuggestBoxProperty
Identifies the AutoSuggestBox dependency property.
public static readonly DependencyProperty AutoSuggestBoxProperty
Field Value
BackRequestedEvent
Identifies the BackRequested routed event.
public static readonly RoutedEvent BackRequestedEvent
Field Value
BreadcrumbBarProperty
Identifies the BreadcrumbBar dependency property.
public static readonly DependencyProperty BreadcrumbBarProperty
Field Value
CompactPaneLengthProperty
Identifies the CompactPaneLength dependency property.
public static readonly DependencyProperty CompactPaneLengthProperty
Field Value
ContentOverlayProperty
Identifies the ContentOverlay dependency property.
public static readonly DependencyProperty ContentOverlayProperty
Field Value
EnableDebugMessagesProperty
Identifies the EnableDebugMessages dependency property.
public static readonly DependencyProperty EnableDebugMessagesProperty
Field Value
FooterMenuItemsProperty
Identifies the FooterMenuItems dependency property.
public static readonly DependencyProperty FooterMenuItemsProperty
Field Value
FooterMenuItemsSourceProperty
Identifies the FooterMenuItemsSource dependency property.
public static readonly DependencyProperty FooterMenuItemsSourceProperty
Field Value
FrameMarginProperty
Identifies the FrameMargin dependency property.
public static readonly DependencyProperty FrameMarginProperty
Field Value
HeaderContentProperty
Registers attached property NavigationView.HeaderContent
public static readonly DependencyProperty HeaderContentProperty
Field Value
HeaderProperty
Identifies the Header dependency property.
public static readonly DependencyProperty HeaderProperty
Field Value
HeaderVisibilityProperty
Identifies the HeaderVisibility dependency property.
public static readonly DependencyProperty HeaderVisibilityProperty
Field Value
IsBackButtonVisibleProperty
Identifies the IsBackButtonVisible dependency property.
public static readonly DependencyProperty IsBackButtonVisibleProperty
Field Value
IsBackEnabledProperty
Identifies the IsBackEnabled dependency property.
public static readonly DependencyProperty IsBackEnabledProperty
Field Value
IsPaneOpenProperty
Identifies the IsPaneOpen dependency property.
public static readonly DependencyProperty IsPaneOpenProperty
Field Value
IsPaneToggleVisibleProperty
Identifies the IsPaneToggleVisible dependency property.
public static readonly DependencyProperty IsPaneToggleVisibleProperty
Field Value
IsPaneVisibleProperty
Identifies the IsPaneVisible dependency property.
public static readonly DependencyProperty IsPaneVisibleProperty
Field Value
ItemInvokedEvent
Identifies the ItemInvoked routed event.
public static readonly RoutedEvent ItemInvokedEvent
Field Value
ItemTemplateProperty
Identifies the ItemTemplate dependency property.
public static readonly DependencyProperty ItemTemplateProperty
Field Value
MenuItemsProperty
Identifies the MenuItems dependency property.
public static readonly DependencyProperty MenuItemsProperty
Field Value
MenuItemsSourceProperty
Identifies the MenuItemsSource dependency property.
public static readonly DependencyProperty MenuItemsSourceProperty
Field Value
NavigatedEvent
Identifies the Navigated routed event.
public static readonly RoutedEvent NavigatedEvent
Field Value
NavigatingEvent
Identifies the Navigating routed event.
public static readonly RoutedEvent NavigatingEvent
Field Value
OpenPaneLengthProperty
Identifies the OpenPaneLength dependency property.
public static readonly DependencyProperty OpenPaneLengthProperty
Field Value
PaneClosedEvent
Identifies the PaneClosed routed event.
public static readonly RoutedEvent PaneClosedEvent
Field Value
PaneDisplayModeProperty
Identifies the PaneDisplayMode dependency property.
public static readonly DependencyProperty PaneDisplayModeProperty
Field Value
PaneFooterProperty
Identifies the PaneFooter dependency property.
public static readonly DependencyProperty PaneFooterProperty
Field Value
PaneHeaderProperty
Identifies the PaneHeader dependency property.
public static readonly DependencyProperty PaneHeaderProperty
Field Value
PaneOpenedEvent
Identifies the PaneOpened routed event.
public static readonly RoutedEvent PaneOpenedEvent
Field Value
PaneTitleProperty
Identifies the PaneTitle dependency property.
public static readonly DependencyProperty PaneTitleProperty
Field Value
SelectionChangedEvent
Identifies the SelectionChanged routed event.
public static readonly RoutedEvent SelectionChangedEvent
Field Value
TitleBarProperty
Identifies the TitleBar dependency property.
public static readonly DependencyProperty TitleBarProperty
Field Value
TransitionDurationProperty
Identifies the TransitionDuration dependency property.
public static readonly DependencyProperty TransitionDurationProperty
Field Value
TransitionProperty
Identifies the Transition dependency property.
public static readonly DependencyProperty TransitionProperty
Field Value
Properties
AlwaysShowHeader
Gets or sets a value indicating whether the header is always visible.
public bool AlwaysShowHeader { get; set; }
Property Value
AutoSuggestBox
Gets or sets an AutoSuggestBox to be displayed in the NavigationView.
public AutoSuggestBox? AutoSuggestBox { get; set; }
Property Value
AutoSuggestBoxSymbolButton
Gets or sets the control that is visitable if PaneDisplayMode="Left" and in compact state
protected Button? AutoSuggestBoxSymbolButton { get; set; }
Property Value
BackButton
Gets or sets the control located at the top of the pane with left arrow icon.
protected Button? BackButton { get; set; }
Property Value
BreadcrumbBar
Gets or sets an BreadcrumbBar that is in Header.
public BreadcrumbBar? BreadcrumbBar { get; set; }
Property Value
CanGoBack
Gets a value indicating whether there is at least one entry in back navigation history.
public bool CanGoBack { get; }
Property Value
CompactPaneLength
Gets or sets the width of the NavigationView pane in its compact display mode.
public double CompactPaneLength { get; set; }
Property Value
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
EnableDebugMessages
Gets or sets a value indicating whether debugging messages for this control are enabled
public bool EnableDebugMessages { get; set; }
Property Value
FooterMenuItems
Gets the list of objects to be used as navigation items in the footer menu.
public IList FooterMenuItems { get; }
Property Value
FooterMenuItemsItemsControl
Gets or sets the control located at the top of the pane with hamburger icon.
protected ItemsControl FooterMenuItemsItemsControl { get; set; }
Property Value
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
FrameMargin
Gets or sets margin for a Frame of INavigationView
public Thickness FrameMargin { get; set; }
Property Value
Header
Gets or sets the header content.
public object? Header { get; set; }
Property Value
HeaderVisibility
Gets or sets the Header visibility.
public Visibility HeaderVisibility { get; set; }
Property Value
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
IsBackEnabled
Gets a value indicating whether the back button is enabled or disabled.
public bool IsBackEnabled { get; protected set; }
Property Value
IsPaneOpen
Gets or sets a value indicating whether the NavigationView pane is expanded to its full width.
public bool IsPaneOpen { get; set; }
Property Value
IsPaneToggleVisible
Gets or sets a value indicating whether the toggle button is visible.
public bool IsPaneToggleVisible { get; set; }
Property Value
IsPaneVisible
Gets or sets a value indicating whether the pane is shown.
public bool IsPaneVisible { get; set; }
Property Value
ItemTemplate
Gets or sets the template property for MenuItems and FooterMenuItems.
public ControlTemplate? ItemTemplate { get; set; }
Property Value
Journal
protected List<string> Journal { get; }
Property Value
MenuItems
Gets the collection of menu items displayed in the NavigationView.
public IList MenuItems { get; }
Property Value
MenuItemsItemsControl
Gets or sets the control located at the top of the pane with left arrow icon.
protected ItemsControl MenuItemsItemsControl { get; set; }
Property Value
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
NavigationStack
protected ObservableCollection<INavigationViewItem> NavigationStack { get; }
Property Value
NavigationViewContentPresenter
Gets or sets the control responsible for rendering the content.
protected NavigationViewContentPresenter NavigationViewContentPresenter { get; set; }
Property Value
OpenPaneLength
Gets or sets the width of the NavigationView pane when it's fully expanded.
public double OpenPaneLength { get; set; }
Property Value
PageIdOrTargetTagNavigationViewsDictionary
protected Dictionary<string, INavigationViewItem> PageIdOrTargetTagNavigationViewsDictionary { get; }
Property Value
PageTypeNavigationViewsDictionary
protected Dictionary<Type, INavigationViewItem> PageTypeNavigationViewsDictionary { get; }
Property Value
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
PaneFooter
Gets or sets the content for the pane footer.
public object? PaneFooter { get; set; }
Property Value
PaneHeader
Gets or sets the content for the pane header.
public object? PaneHeader { get; set; }
Property Value
PaneTitle
Gets or sets the label adjacent to the menu icon when the NavigationView pane is open.
public string? PaneTitle { get; set; }
Property Value
SelectedItem
Gets the selected item.
public INavigationViewItem? SelectedItem { get; protected set; }
Property Value
TitleBar
Gets or sets an TitleBar to be displayed in the NavigationView.
public TitleBar? TitleBar { get; set; }
Property Value
ToggleButton
Gets or sets the control located at the top of the pane with hamburger icon.
protected Button? ToggleButton { get; set; }
Property Value
Transition
Gets or sets type of INavigationView transitions during navigation.
public Transition Transition { get; set; }
Property Value
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
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
objecte
RoutedEventArgs
BreadcrumbBarOnItemClicked(BreadcrumbBar, BreadcrumbBarItemClickedEventArgs)
protected virtual void BreadcrumbBarOnItemClicked(BreadcrumbBar sender, BreadcrumbBarItemClickedEventArgs e)
Parameters
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
FrameworkElementFrameworkElement 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
GoForward()
Navigates the NavigationView to the next journal entry.
public virtual bool GoForward()
Returns
Navigate(string, object?)
Synchronously navigates current navigation Frame to the given Element.
public virtual bool Navigate(string pageIdOrTargetTag, object? dataContext = null)
Parameters
Returns
Navigate(Type, object?)
Synchronously navigates current navigation Frame to the given Element.
public virtual bool Navigate(Type pageType, object? dataContext = null)
Parameters
Returns
NavigateToMenuItemFromAutoSuggestBox(IEnumerable, string)
protected virtual bool NavigateToMenuItemFromAutoSuggestBox(IEnumerable list, string selectedSuggestBoxItem)
Parameters
list
IEnumerableselectedSuggestBoxItem
string
Returns
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
Returns
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
objecte
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
EventArgsThe 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
MouseButtonEventArgsThe 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
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
objecte
SizeChangedEventArgs
OnToggleButtonClick(object, RoutedEventArgs)
This virtual method is called when ToggleButton is clicked.
protected virtual void OnToggleButtonClick(object sender, RoutedEventArgs e)
Parameters
sender
objecte
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
objecte
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
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
Returns
SetHeaderContent(FrameworkElement, object?)
Helper for setting HeaderContentProperty on target
.
public static void SetHeaderContent(FrameworkElement target, object? headerContent)
Parameters
target
FrameworkElementFrameworkElement to set HeaderContentProperty on.
headerContent
objectHeaderContent 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
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
Navigated
Occurs when navigated to page
public event TypedEventHandler<NavigationView, NavigatedEventArgs> Navigated
Event Type
Navigating
Occurs when a new navigation is requested
public event TypedEventHandler<NavigationView, NavigatingCancelEventArgs> Navigating
Event Type
PaneClosed
Occurs when the NavigationView pane is closed.
public event TypedEventHandler<NavigationView, RoutedEventArgs> PaneClosed
Event Type
PaneOpened
Occurs when the NavigationView pane is opened.
public event TypedEventHandler<NavigationView, RoutedEventArgs> PaneOpened
Event Type
SelectionChanged
Occurs when the currently selected item changes.
public event TypedEventHandler<NavigationView, RoutedEventArgs> SelectionChanged