in XamlControlsGallery/Navigation/NavigationRootPage.xaml.cs [267:319]
private void OnNavigationViewItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewItemInvokedEventArgs args)
{
// Close any open teaching tips before navigation
CloseTeachingTips();
if(args.InvokedItemContainer.IsSelected)
{
// Clicked on an item that is already selected,
// Avoid navigating to the same page again causing movement.
return;
}
if (args.IsSettingsInvoked)
{
if (rootFrame.CurrentSourcePageType != typeof(SettingsPage))
{
rootFrame.Navigate(typeof(SettingsPage));
}
}
else
{
var invokedItem = args.InvokedItemContainer;
if (invokedItem == _allControlsMenuItem)
{
if (rootFrame.CurrentSourcePageType != typeof(AllControlsPage))
{
rootFrame.Navigate(typeof(AllControlsPage));
}
}
else if (invokedItem == _newControlsMenuItem)
{
if (rootFrame.CurrentSourcePageType != typeof(NewControlsPage))
{
rootFrame.Navigate(typeof(NewControlsPage));
}
}
else
{
if (invokedItem.DataContext is ControlInfoDataGroup)
{
var itemId = ((ControlInfoDataGroup)invokedItem.DataContext).UniqueId;
rootFrame.Navigate(typeof(SectionPage), itemId);
}
else if (invokedItem.DataContext is ControlInfoDataItem)
{
var item = (ControlInfoDataItem)invokedItem.DataContext;
rootFrame.Navigate(typeof(ItemPage), item.UniqueId);
}
}
}
}