我正在使用NavigationView
,在NavigationView
中添加了很多项目,并将PaneDisplayMode
设置为LeftCompact
。它将自动显示垂直滚动条。我正试图隐藏它。
[我在generic.xaml中以NavigationView
的样式查找,发现所有项目都在NavigationViewList
中。
<NavigationViewList x:Name="MenuItemsHost" Grid.Row="6" Margin="0,0,0,20"
SelectionMode="Single" IsItemClickEnabled="True" HorizontalAlignment="Stretch"
SelectedItem="{TemplateBinding SelectedItem}" ItemTemplate="{TemplateBinding MenuItemTemplate}"
ItemTemplateSelector="{TemplateBinding MenuItemTemplateSelector}"
ItemContainerStyle="{TemplateBinding MenuItemContainerStyle}"
ItemContainerStyleSelector="{TemplateBinding MenuItemContainerStyleSelector}"
SingleSelectionFollowsFocus="{Binding RelativeSource={RelativeSource TemplatedParent},
Path=TemplateSettings.SingleSelectionFollowsFocus}" />
所以我将NavigationView
的整个样式放入app.xaml中,并添加ScrollViewer.VerticalScrollBarVisibility=Hidden
至NavigationViewList
。没改变。
我还发现NavigationViewList
基于ListView
,因此我将ListView
添加到app.xaml中,并设置为VerticalScrollBarVisibility=Hidden
。均无效。
为什么?
如何在NavigationView中隐藏垂直滚动条?
对于我的测试,它在将NavigationView
添加到ScrollViewer.VerticalScrollBarVisibility=Hidden
的本机NavigationViewList
中起作用,但是对于microsoft-ui-xaml编辑样式将导致列表丢失,这看起来是个问题。我将其报告给生产团队,您也可以将错误报告发布在microsoft-ui-xaml
github issue框中。