且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在ListBox中获得垂直滚动条?

更新时间:2023-11-17 16:26:49

解决方案的问题是,您要将滚动条放在ListBox周围,可能要将其放在ListBox中.

The problem with your solution is you're putting a scrollbar around a ListBox where you probably want to put it inside the ListBox.

如果要在列表框中强制使用滚动条,请使用ScrollBar.VerticalScrollBarVisibility附加属性.

If you want to force a scrollbar in your ListBox, use the ScrollBar.VerticalScrollBarVisibility attached property.

<ListBox 
    ItemsSource="{Binding}" 
    ScrollViewer.VerticalScrollBarVisibility="Visible">
</ListBox>

将此值设置为自动"将根据需要弹出滚动条.

Setting this value to Auto will popup the scrollbar on an as needed basis.