我在 UWP 应用程序中使用导航视图控件,问题是当我单击后退按钮时,焦点元素不会更改为内容框架中显示的项目。例如,点击的元素是 camara、store、musica,然后两次返回按钮以在 contentframe 元素中显示 camara,但 musica 仍然具有焦点(蓝色矩形)
private void FrameNavigated( object sender, NavigationEventArgs e )
{
var currentView = SystemNavigationManager.GetForCurrentView();
if ( ContentFrame.CanGoBack )
{
currentView.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
}
else
{
currentView.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
}
}
private void OnBackRequested( object sender, BackRequestedEventArgs e )
{
if ( ContentFrame.CanGoBack )
{
e.Handled = true;
PageStackEntry pageStackEntry = ContentFrame.BackStack.LastOrDefault();
ContentFrame.GoBack();
if ( pageStackEntry != null )
{
string nombre = pageStackEntry.SourcePageType.Name;
MenuItem item = subItemsMenu.FirstOrDefault(nom => nom.NombrePantalla.Equals(nombre));
navView.SelectedItem = item;
navView.Header = item.Encabezado;
}
}
}
红颜莎娜
慕桂英3389331
相关分类