导航视图为UWP应用程序中的子菜单项设置SelectedItem
我正在尝试通过设置navigationview的默认选定项导航视图为UWP应用程序中的子菜单项设置SelectedItem,uwp,uwp-xaml,navigationview,Uwp,Uwp Xaml,Navigationview,我正在尝试通过设置navigationview的默认选定项 DashboardMenuItem.IsExpanded = true; Microsoft.UI.Xaml.Controls.NavigationViewItem selectedItem =(Microsoft.UI.Xaml.Controls.NavigationViewItem)DashboardMenuItem.MenuItems[0]; NavView.SelectedItem = selectedItem; 这是我的X
DashboardMenuItem.IsExpanded = true;
Microsoft.UI.Xaml.Controls.NavigationViewItem selectedItem =(Microsoft.UI.Xaml.Controls.NavigationViewItem)DashboardMenuItem.MenuItems[0];
NavView.SelectedItem = selectedItem;
这是我的XAML
<MUXC:NavigationView.MenuItems>
<MUXC:NavigationViewItem
x:Name="DashboardMenuItem"
Content="{x:Bind DashboardLabel}"
Foreground="#FFFFFF"
ToolTipService.ToolTip="{x:Bind DashboardLabel}">
<MUXC:NavigationViewItem.Icon>
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="" />
</MUXC:NavigationViewItem.Icon>
<MUXC:NavigationViewItem.MenuItems>
<MUXC:NavigationViewItem
x:Name="ListofPersonMenuItem"
Content="{x:Bind ListofPersonLabel}"
Foreground="#FFFFFF"
ToolTipService.ToolTip="{x:Bind ListofPersonLabel}" />
<MUXC:NavigationViewItem
x:Name="ListofDiedPersonsMenuItem"
Content="{x:Bind ListofDiedPersonsLabel}"
Foreground="#FFFFFF"
ToolTipService.ToolTip="{x:Bind ListofDiedPersonsLabel}" />
</MUXC:NavigationViewItem.MenuItems>
</MUXC:NavigationViewItem>
但是我的菜单项只有一个突出显示的背景,仍然没有我们点击选择时的左栏。下面的图片链接(很抱歉,因为我还不能发布图片)
那么,你对此有什么建议吗
提前感谢
导航视图为UWP应用程序中的子菜单项设置SelectedItem
在测试过程中,问题是扩展动画块选择动画,使项目指示器关闭。目前,我们有一种解决方法,在设置SelectedItem
之前添加任务延迟。它将在仪表板菜单项扩展后执行选择动画
DashboardMenuItem.IsExpanded = true;
Microsoft.UI.Xaml.Controls.NavigationViewItem selectedItem = (Microsoft.UI.Xaml.Controls.NavigationViewItem)DashboardMenuItem.MenuItems[0];
await Task.Delay(100);
MainNavigation.SelectedItem = selectedItem;