在WPF ListBox中禁用水平滚动,可以通过以下几种方法实现:
<ListBox>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
<ListBox>
<!-- ListBox Items -->
</ListBox>
</ScrollViewer>
<ListBox>
<ListBox.Resources>
<Style TargetType="{x:Type ScrollViewer}">
<Setter Property="HorizontalScrollBarVisibility" Value="Disabled"/>
</Style>
</ListBox.Resources>
<!-- ListBox Items -->
</ListBox>
以上三种方法都可以有效地禁用ListBox中的水平滚动条,从而实现更好的用户体验。
领取专属 10元无门槛券
手把手带您无忧上云