private void OnNavigatingToPage(object sender, NavigatingCancelEventArgs e) { if (e.NavigationMode != NavigationMode.Back || !TopNavigationItems.Any()) { return; } var item = TopNavigationItems.SingleOrDefault(p => p.DestinationPage == e.SourcePageType); if (item == null && _pageFrame.BackStackDepth > 0) { foreach (var entry in _pageFrame.BackStack.Reverse()) { item = TopNavigationItems.SingleOrDefault(p => p.DestinationPage == entry.SourcePageType); if (item != null) { break; } } } var container = (ListViewItem)_navTopMenuListView.ContainerFromItem(item); if (container != null) { container.IsTabStop = false; } _navTopMenuListView.SetSelectedItem(container); if (container != null) { container.IsTabStop = true; } }
private void OnNavigatingToPage(object sender, NavigatingCancelEventArgs e) { if (e.NavigationMode != NavigationMode.Back || !TopNavigationItems.Any()) { return; } var item = GetItemFromList(e.SourcePageType); if (item == null && _pageFrame.BackStackDepth > 0) { foreach (var entry in _pageFrame.BackStack.Reverse()) { if (entry.SourcePageType == typeof(PlaylistView)) { var para = entry.Parameter; //get previous entry's parameter if (para is Playlist) { item = PlaylistsItems.SingleOrDefault(p => p.Label == (para as Playlist).Name); //search for the item in PlaylistItems with the same label as in parameters Name. } else if (para is Album) { _pageFrame.Navigate(typeof(PlaylistView), para as Album); return; } } else if (entry.SourcePageType == typeof(LibraryView)) { var para = entry.Parameter; if (para != null) { item = TopNavigationItems.SingleOrDefault(t => t.Arguments == para); } else { item = TopNavigationItems[1]; } } if (item != null) { break; //if item is successfully got break the loop. We got what we needed. } } } if (item != null) { var container = (ListViewItem)GetParentListViewFromItem(item as SimpleNavMenuItem).ContainerFromItem(item); if (container != null) { container.IsTabStop = false; } GetParentListViewFromItem(item as SimpleNavMenuItem).SetSelectedItem(container); container.IsSelected = true; if (container != null) { container.IsTabStop = true; } } }
INavigationMenuItem GetItemFromList(Type sourcePagetype) { if (sourcePagetype == typeof(LibraryView)) { return(TopNavigationItems.SingleOrDefault(p => p.DestinationPage == sourcePagetype)); } else if (sourcePagetype == typeof(PlaylistView)) { return(null); } else { return(BottomNavigationItems.SingleOrDefault(p => p.DestinationPage == sourcePagetype)); } }