I need to Scroll NavigationView to its SelectedItem. In which I tried below methods one with TryMoveFocusAsync and another by tring to get ScrollViewer through parent of the SelectedItem from SelectionChanged event. But, the parent seems to be null.
Note: NavigationView doesn't have ScrollIntoView like ListView
1st Method
private async void OnSelectionChanged(
NavigationView sender, NavigationViewSelectionChangedEventArgs args)
{
if (args.SelectedItem is NavigationViewItem item)
{
FocusManager.TryFocusAsync(
sender.SelectedItem as DependencyObject,
FocusState.Pointer);
ViewModel.NavigateTo(item.Name);
}
UpdateBackButton();
}
2nd Method
private async void OnSelectionChanged(
NavigationView sender, NavigationViewSelectionChangedEventArgs args)
(args.SelectedItem as NavigationViewItem).Parent returns null.
Is there a way to scroll the NavigationViewMenuItem to its selected index?