/// <summary> /// Ensures the nav menu reflects reality when navigation is triggered outside of /// the nav menu buttons. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnNavigatingToPage(object sender, NavigatingCancelEventArgs e) { if (e.NavigationMode == NavigationMode.Back) { var item = (from p in navlistTop.Union(navlistBottom) where p.DestPage == e.SourcePageType select p) .SingleOrDefault(); if (item == null && AppMyFrame.BackStackDepth > 0) { // In cases where a page drills into sub-pages then we'll highlight the most recent // navigation menu item that appears in the BackStack foreach (var entry in AppMyFrame.BackStack.Reverse()) { item = (from p in navlistTop.Union(navlistBottom) where p.DestPage == entry.SourcePageType select p) .SingleOrDefault(); if (item != null) { break; } } } var container = (ListViewItem)NavMenuListTop.ContainerFromItem(item); if (container == null) { container = (ListViewItem)NavMenuListBottom.ContainerFromItem(item); // While updating the selection state of the item prevent it from taking keyboard focus. If a // user is invoking the back button via the keyboard causing the selected nav menu item to change // then focus will remain on the back button. //this is for the bottom section if (container != null) { container.IsTabStop = false; } NavMenuListBottom.SetSelectedItem(container); if (container != null) { container.IsTabStop = true; } //reset the top section NavMenuListTop.SetSelectedItem(null); } else { // and this is for the top section container.IsTabStop = false; NavMenuListTop.SetSelectedItem(container); container.IsTabStop = true; //reset the bottom section NavMenuListBottom.SetSelectedItem(null); } } //Change the theme on page navigation; maybe it can be moved somewhere else. SetColor(); }
/// <summary> /// Navigate to the Page for the selected <paramref name="listViewItem" />. /// </summary> /// <param name="sender"></param> /// <param name="listViewItem"></param> private async void NavMenuList_ItemInvoked(object sender, ListViewItem listViewItem) { var item = (NavMenuItem)((NavMenuListView)sender).ItemFromContainer(listViewItem); if (item?.DestPage != null && item.DestPage != MyAppFrame.CurrentSourcePageType) { if (item.DestViewModel == typeof(AccountListViewModel)) { await ViewModel.ShowAccountListCommand.ExecuteAsync(); } else if (item.DestViewModel == typeof(StatisticSelectorViewModel)) { await ViewModel.ShowStatisticSelectorCommand.ExecuteAsync(); } else if (item.DestViewModel == typeof(CategoryListViewModel)) { await ViewModel.ShowCategoryListCommand.ExecuteAsync(); } else if (item.DestViewModel == typeof(BackupViewModel)) { await ViewModel.ShowBackupViewCommand.ExecuteAsync(); } else if (item.DestViewModel == typeof(SettingsViewModel)) { await ViewModel.ShowSettingsCommand.ExecuteAsync(); } else if (item.DestViewModel == typeof(AboutViewModel)) { await ViewModel.ShowAboutCommand.ExecuteAsync(); } } //reset the bottom or top section depending on which section the user clicked if (sender.Equals(NavMenuListTop)) { NavMenuListBottom.SetSelectedItem(null); } else { NavMenuListTop.SetSelectedItem(null); } }
private void NavMenuList_SelectionChanged(object sender, SelectionChangedEventArgs e) { //Show the back button SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; //Change the title var selectedItem = (sender as NavMenuListView).SelectedValue; PageTitle.Text = (selectedItem as NavMenuItem)?.Label ?? "There should be a title here."; //Deselect the other item if (sender.Equals(NavMenuList)) { NavMenuListBottom.SetSelectedItem(null); } else { NavMenuList.SetSelectedItem(null); } }
/// <summary> /// Navigate to the Page for the selected <paramref name="listViewItem" />. /// </summary> /// <param name="sender"></param> /// <param name="listViewItem"></param> private void NavMenuList_ItemInvoked(object sender, ListViewItem listViewItem) { var item = (NavMenuItem)((NavMenuListView)sender).ItemFromContainer(listViewItem); if (item?.DestPage != null && item.DestPage != MyAppFrame.CurrentSourcePageType) { ViewModel.ShowViewModelByType(item.DestViewModel); } //reset the bottom or top section depending on which section the user clicked if (sender.Equals(NavMenuListTop)) { NavMenuListBottom.SetSelectedItem(null); } else { NavMenuListTop.SetSelectedItem(null); } }