【发布时间】:2020-11-26 06:58:58
【问题描述】:
我试图通过设置导航视图的默认选定项
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>
但是我的菜单项只有一个高亮背景,仍然没有像我们单击选择时那样的左侧栏。图片链接如下(抱歉,我还不能发布图片)
https://i.gyazo.com/f2953c8f092534ea26ceb7fef0120de2.png
那么,请问您对此有什么建议吗?
提前致谢
【问题讨论】:
标签: uwp uwp-xaml navigationview