如何禁用水平滚动一个WPF列表框?水平、列表、WPF

2023-09-03 09:07:18 作者:梦里没有你

这似乎是一个太简单的问题,但谷歌和SO搜索得到什么。如何禁用水平滚动一个WPF列表框中的项目占用更多的横向空间比可用在箱子里?

This seems to be an absurdly simple question but Google and SO searches yield nothing. How can I disable horizontal scrolling in a WPF listbox when items take up more horizontal space than is available in the box?

推荐答案

在XAML:

<ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled" />

在C#:

In C#:

myListBox.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled);
 
精彩推荐
图片推荐