Skip to content

Commit

Permalink
Change ItemInvoked->SelectionChanged on NavigationRootPage (microsoft…
Browse files Browse the repository at this point in the history
  • Loading branch information
bpulliam committed Mar 15, 2022
1 parent 19b9cf0 commit e97be1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
2 changes: 1 addition & 1 deletion XamlControlsGallery/Navigation/NavigationRootPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
PaneOpening="NavigationViewControl_PaneOpening"
PaneClosing="NavigationViewControl_PaneClosing"
DisplayModeChanged="NavigationViewControl_DisplayModeChanged"
ItemInvoked="OnNavigationViewItemInvoked"
SelectionChanged="OnNavigationViewSelectionChanged"
Loaded="OnNavigationViewControlLoaded">
<muxc:NavigationView.AutoSuggestBox>
<AutoSuggestBox
Expand Down
25 changes: 9 additions & 16 deletions XamlControlsGallery/Navigation/NavigationRootPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,19 +264,12 @@ private void OnNavigationViewControlLoaded(object sender, RoutedEventArgs e)
Task.Delay(500).ContinueWith(_ => this.NavigationViewLoaded?.Invoke(), TaskScheduler.FromCurrentSynchronizationContext());
}

private void OnNavigationViewItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewItemInvokedEventArgs args)
private void OnNavigationViewSelectionChanged(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewSelectionChangedEventArgs 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 (args.IsSettingsSelected)
{
if (rootFrame.CurrentSourcePageType != typeof(SettingsPage))
{
Expand All @@ -285,16 +278,16 @@ private void OnNavigationViewItemInvoked(Microsoft.UI.Xaml.Controls.NavigationVi
}
else
{
var invokedItem = args.InvokedItemContainer;
var selectedItem = args.SelectedItemContainer;

if (invokedItem == _allControlsMenuItem)
if (selectedItem == _allControlsMenuItem)
{
if (rootFrame.CurrentSourcePageType != typeof(AllControlsPage))
{
rootFrame.Navigate(typeof(AllControlsPage));
}
}
else if (invokedItem == _newControlsMenuItem)
else if (selectedItem == _newControlsMenuItem)
{
if (rootFrame.CurrentSourcePageType != typeof(NewControlsPage))
{
Expand All @@ -303,14 +296,14 @@ private void OnNavigationViewItemInvoked(Microsoft.UI.Xaml.Controls.NavigationVi
}
else
{
if (invokedItem.DataContext is ControlInfoDataGroup)
if (selectedItem.DataContext is ControlInfoDataGroup)
{
var itemId = ((ControlInfoDataGroup)invokedItem.DataContext).UniqueId;
var itemId = ((ControlInfoDataGroup)selectedItem.DataContext).UniqueId;
rootFrame.Navigate(typeof(SectionPage), itemId);
}
else if (invokedItem.DataContext is ControlInfoDataItem)
else if (selectedItem.DataContext is ControlInfoDataItem)
{
var item = (ControlInfoDataItem)invokedItem.DataContext;
var item = (ControlInfoDataItem)selectedItem.DataContext;
rootFrame.Navigate(typeof(ItemPage), item.UniqueId);
}

Expand Down

0 comments on commit e97be1e

Please sign in to comment.