Skip to content

Commit

Permalink
Fix NavigationViewItem Expand crash #20
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost1372 committed Jan 2, 2025
1 parent 51ec4ed commit a2d6e9b
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ public void EnsureNavigationSelection(string id)
group.IsSelected = true;
_navigationView.SelectedItem = group;

group.IsExpanded = true;
if (group.MenuItems.Count > 0)
{
group.IsExpanded = true;
}
return;
}

Expand All @@ -218,8 +221,10 @@ private bool EnsureNavigationSelectionBase(object rawItem, string id, Navigation
_navigationView.SelectedItem = item;
item.IsSelected = true;

parentGroup.IsExpanded = true;

if (parentGroup.MenuItems.Count > 0)
{
parentGroup.IsExpanded = true;
}
return true;
}

Expand Down Expand Up @@ -280,7 +285,10 @@ public bool EnsureItemIsVisibleInNavigation(string name)
else
{
// Expand so we animate
item.IsExpanded = true;
if (item.MenuItems.Count > 0)
{
item.IsExpanded = true;
}
// Ensure parent is expanded so we actually show the selection indicator
_navigationView.UpdateLayout();
// Set selected item
Expand Down

0 comments on commit a2d6e9b

Please sign in to comment.