private void OnNavigateBack(NavigationView sender, NavigationViewBackRequestedEventArgs args) { if (Common.BaseFrame.CanGoBack) { Common.BaseFrame.GoBack(); } }
/// <summary> /// Initializes a new instance of the <see cref="RootNavigationHelper"/> class. /// </summary> /// <param name="rootFrame">A reference to the top-level frame. /// This reference allows for frame manipulation and to register navigation handlers.</param> public RootFrameNavigationHelper(Frame rootFrame, Windows.UI.Xaml.Controls.NavigationView currentNavView) { this.Frame = rootFrame; this.Frame.Navigated += (s, e) => { // Update the Back button whenever a navigation occurs. UpdateBackButton(); //当导航发生时自动更新导航控件左侧所选项目 UpdateNavigationViewSelectedItem(e.NavigationMode); }; this.CurrentNavView = currentNavView; this.GoBackViewItemStack = new Stack <object>(); this.GoForwardViewItemStack = new Stack <object>(); // Handle keyboard and mouse navigation requests this.systemNavigationManager = SystemNavigationManager.GetForCurrentView(); systemNavigationManager.BackRequested += SystemNavigationManager_BackRequested; // must register back requested on navview if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 6)) { CurrentNavView.BackRequested += NavView_BackRequested; } // Listen to the window directly so we will respond to hotkeys regardless // of which element has focus. Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += CoreDispatcher_AcceleratorKeyActivated; Window.Current.CoreWindow.PointerPressed += this.CoreWindow_PointerPressed; }
private void NavView_SelectionChanged( Windows.UI.Xaml.Controls.NavigationView sender, NavigationViewSelectionChangedEventArgs args) { if (args.IsSettingsSelected) { MyFrame.Navigate(typeof(SettingsPage)); } else { NavigationViewItem item = args.SelectedItem as NavigationViewItem; switch (item.Tag) { case "loging": MyFrame.Navigate(typeof(logingPage)); break; case "games": MyFrame.Navigate(typeof(gamePage)); break; } } }
private async void NavMain_OnSelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args) { NavigationViewItem nowitem = (NavigationViewItem)sender.SelectedItem; if (nowitem.Tag.ToString() == "PageMe" && !Common.Logined) { await DialogLogin.ShowAsync(); return; } switch (nowitem.Tag.ToString()) { case "PageMe": Common.BaseFrame.Navigate(typeof(Pages.Me), null, new EntranceNavigationTransitionInfo()); break; case "PageHome": Common.BaseFrame.Navigate(typeof(Pages.Home), null, new EntranceNavigationTransitionInfo()); break; case "PageSearch": Common.BaseFrame.Navigate(typeof(Search), null, new EntranceNavigationTransitionInfo()); break; case "PageSettings": Common.BaseFrame.Navigate(typeof(Pages.Settings), null, new EntranceNavigationTransitionInfo()); break; } }
/// <summary> /// Navigates the frame to the previous page. /// </summary> private void NavigationView_BackRequested(Windows.UI.Xaml.Controls.NavigationView sender, Windows.UI.Xaml.Controls.NavigationViewBackRequestedEventArgs args) { if (AppFrame.CanGoBack) { AppFrame.GoBack(); } }
public void Initialize(Frame frame, WinUI.NavigationView navigationView, IList <KeyboardAccelerator> keyboardAccelerators) { _navigationView = navigationView; _keyboardAccelerators = keyboardAccelerators; NavigationService.Frame = frame; NavigationService.NavigationFailed += Frame_NavigationFailed; NavigationService.Navigated += Frame_Navigated; _navigationView.BackRequested += OnBackRequested; }
private void NavView_OnBackRequested( Windows.UI.Xaml.Controls.NavigationView sender, NavigationViewBackRequestedEventArgs args) { if (RibbonFrame.CanGoBack) { RibbonFrame.GoBack(); } }
private void NavigationView_ItemInvoked(Windows.UI.Xaml.Controls.NavigationView sender, NavigationViewItemInvokedEventArgs args) { if (!args.IsSettingsInvoked) { // find NavigationViewItem with Content that equals InvokedItem var item = sender.MenuItems.OfType <NavigationViewItem>().First(x => (string)x.Content == (string)args.InvokedItem); NavView_Navigate(item as NavigationViewItem); } }
private void NavView_ItemInvoked(XamlIslands.NavigationView sender, XamlIslands.NavigationViewItemInvokedEventArgs args) { if (args.IsSettingsInvoked) { } else if (args.InvokedItemContainer != null) { var navItemTag = args.InvokedItemContainer.Tag.ToString(); MessageBox.Show(navItemTag); } }
/// <summary> /// Navigates to the page corresponding to the tapped item. /// </summary> private void NavigationView_ItemInvoked(Windows.UI.Xaml.Controls.NavigationView sender, Windows.UI.Xaml.Controls.NavigationViewItemInvokedEventArgs args) { var label = args.InvokedItem as string; var pageType = args.IsSettingsInvoked ? typeof(SettingsPage) : label == CustomerListLabel ? typeof(CustomerListPage) : label == OrderListLabel ? typeof(OrderListPage) : null; if (pageType != null && pageType != AppFrame.CurrentSourcePageType) { AppFrame.Navigate(pageType); } }
private void MyNavView_ChildChanged(object sender, EventArgs e) { if (MyNavView.Child is XamlIslands.NavigationView navigationView) { _navView = navigationView; _navView.RequestedTheme = ElementTheme.Light; _navView.IsBackButtonVisible = XamlIslands.NavigationViewBackButtonVisible.Visible; _navView.PaneDisplayMode = XamlIslands.NavigationViewPaneDisplayMode.Left; _navView.MenuItems.Add(CreateMenu("Home")); _navView.MenuItems.Add(CreateMenu("Admin")); _navView.ItemInvoked += NavView_ItemInvoked; } }
private void NavigationView_OnItemInvoked(Windows.UI.Xaml.Controls.NavigationView sender, NavigationViewItemInvokedEventArgs args) { var item = args.InvokedItemContainer as NavigationViewItem; if (item == null || item == _lastItem) { return; } var clickedView = item.Tag?.ToString() ?? "SettingsPage"; if (!NavigateToView(clickedView)) { return; } _lastItem = item; }
private void MainNaviView_SelectionChanged(Windows.UI.Xaml.Controls.NavigationView sender, Windows.UI.Xaml.Controls.NavigationViewSelectionChangedEventArgs args) { if (args.IsSettingsSelected) { } else { NavigationViewItem item = args.SelectedItem as NavigationViewItem; switch (item.Tag.ToString()) { case Const.NaviActivity: MainFrame.Navigate(typeof(NewsPage)); //sender.Header = "Activity"; break; case Const.NaviNotif: //sender.Header = "Notification"; break; case Const.NaviTrend: //sender.Header = "Trend"; break; case Const.NaviIssue: //sender.Header = "Issue"; break; case Const.NaviProfile: MainFrame.Navigate(typeof(ProfilePage)); //sender.Header = "My Profile"; break; case Const.NaviMyRepos: //sender.Header = "My Repositories"; break; case Const.NaviMyStarred: //sender.Header = "My Starred"; break; case Const.NaviBookmarks: //sender.Header = "My Bookmark"; break; } } }
private void NavView_SelectionChanged(Windows.UI.Xaml.Controls.NavigationView sender, Windows.UI.Xaml.Controls.NavigationViewSelectionChangedEventArgs args) { Windows.UI.Xaml.Controls.NavigationViewItem e = sender.SelectedItem as Windows.UI.Xaml.Controls.NavigationViewItem; String Name = e.Name.ToString(); switch (Name) { case "SearchFrame": contentFrame.Navigate(typeof(SearchPage)); break; case "SettingsPage": contentFrame.Navigate(typeof(CodeSettingsPage)); break; case "DocumentFrame": contentFrame.Navigate(typeof(DocumentPage)); break; } }
private void NavigationView_SelectionChanged(UIControls.NavigationView sender, UIControls.NavigationViewSelectionChangedEventArgs args) { try { if (args.SelectedItem is UIControls.NavigationViewItem item) { switch (item.Content) { case "Home": frame.Content = new HomePage(); break; case "Shop": frame.Content = new ShopPage(); break; case "Payments": frame.Content = new PaymentsPage(); break; case "Reports": frame.Content = new ReportsPage(); break; case "Locate Branch": frame.Content = new BranchPage(); break; case "Profile Settings": frame.Content = new ProfileSettingsPage(); break; default: break; } } } catch (Exception) { } }
/// <summary> /// Navigationm from shell menu /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void NavView_ItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args) { if (args.IsSettingsInvoked) { HamMen.NavigationService.Navigate(settingsPageType); } else { if (args.InvokedItem is string itemText && navView.MenuItems.FirstOrDefault(x => ((x as NavigationViewItem).Content as string) == itemText) is NavigationViewItem navItem) { if (navItem.Tag is Type modulePageType) { HamMen.NavigationService.Navigate(modulePageType, infoOverride: new SuppressNavigationTransitionInfo()); } else { HamMen.NavigationService.Navigate(mainPageType, infoOverride: new SuppressNavigationTransitionInfo()); } } } }
private void NavView_SelectionChanged( Windows.UI.Xaml.Controls.NavigationView sender, NavigationViewSelectionChangedEventArgs args) { if (args.IsSettingsSelected) { NavView.Header = "SettingsPage"; } else { NavigationViewItem item = args.SelectedItem as NavigationViewItem; switch (item.Tag) { case "PortraitItem": NavView.Header = "Portrait"; Frame.Navigate(typeof(Page1)); break; case "SceneryItem": NavView.Header = "Scenery"; Frame.Navigate(typeof(scenery)); break; case "FoodItem": NavView.Header = "Food"; Frame.Navigate(typeof(food)); break; case "DrawItem": NavView.Header = "Draw"; Frame.Navigate(typeof(draw)); break; } } }
protected override void OnApplyTemplate() { var visual = ElementCompositionPreview.GetElementVisual(this); NavigationView.CreateAndAttachHeaderAnimation(visual); }
private void OnBackRequested(WinUI.NavigationView sender, WinUI.NavigationViewBackRequestedEventArgs args) { NavigationService.GoBack(); }
internal void SetNavigationViewParent(NavigationView navigationView) { m_navigationView = new WeakReference <NavigationView>(navigationView); }
/// <summary> /// Navigationview selection changed /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void NavView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args) { // Is it really needed? }
private void NavView_BackRequested(Windows.UI.Xaml.Controls.NavigationView sender, Windows.UI.Xaml.Controls.NavigationViewBackRequestedEventArgs args) { TryGoBack(); }