private void OpenSidebarItem(Microsoft.UI.Xaml.Controls.NavigationViewItemBase invokedItemContainer) { string navigationPath; // path to navigate Type sourcePageType = null; // type of page to navigate switch ((invokedItemContainer.DataContext as INavigationControlItem).ItemType) { case NavigationControlItemType.Location: { var ItemPath = (invokedItemContainer.DataContext as INavigationControlItem).Path; // Get the path of the invoked item if (ItemPath.Equals("Home", StringComparison.OrdinalIgnoreCase)) // Home item { if (ItemPath.Equals(SelectedSidebarItem?.Path, StringComparison.OrdinalIgnoreCase)) { return; // return if already selected } navigationPath = "NewTab".GetLocalized(); sourcePageType = typeof(YourHome); } else // Any other item { navigationPath = invokedItemContainer.Tag.ToString(); } break; } case NavigationControlItemType.OneDrive: { navigationPath = App.AppSettings.OneDrivePath; break; } default: { navigationPath = invokedItemContainer.Tag.ToString(); break; } } if (string.IsNullOrEmpty(navigationPath) || (!string.IsNullOrEmpty(App.CurrentInstance.FilesystemViewModel.WorkingDirectory) && navigationPath.TrimEnd(Path.DirectorySeparatorChar).Equals( App.CurrentInstance.FilesystemViewModel.WorkingDirectory.TrimEnd(Path.DirectorySeparatorChar), StringComparison.OrdinalIgnoreCase))) // return if already selected { return; } App.CurrentInstance.ContentFrame.Navigate( sourcePageType == null ? App.AppSettings.GetLayoutType() : sourcePageType, navigationPath, new SuppressNavigationTransitionInfo()); App.CurrentInstance.NavigationToolbar.PathControlDisplayText = App.CurrentInstance.FilesystemViewModel.WorkingDirectory; }
private void NavigateToPage(Microsoft.UI.Xaml.Controls.NavigationViewItemBase target, NavigationTransitionInfo info) { FrameNavigationOptions navOptions = new FrameNavigationOptions { TransitionInfoOverride = info }; foreach (MainPageNavigationPage page in PAGES) { if (page.NAV_ITEM == target) { UiUtils.NavigateToType(page.TARGET_PAGE, null, contentFrame, navOptions); titleBar.Text = page.PAGE_NAME; return; } } }
public SidebarItemInvokedEventArgs(Microsoft.UI.Xaml.Controls.NavigationViewItemBase ItemContainer) { InvokedItemContainer = ItemContainer; }