我有 ItemControl
它为 ObservableCollection
中的每条记录显示一个面板。
我的问题是……
当 ObservableCollection 增加窗口的大小无法容纳更多面板时,它会显示仅前六个面板。
因此,ObservableCollection 中每条记录的一个面板无法完成。
所以,我需要有滚动条,这样我才能访问每个面板。 如何实现?
请参阅下面的屏幕截图和 Code在这里
谢谢......
最佳答案
您需要在 ScrollViewer
中托管您的面板。这允许它超出可用空间,同时 ScrollViewer
添加了一个滚动条。
您可以通过修改 ItemsControl
模板来做到这一点:
<ItemsControl>
<ItemsControl.Template>
<ControlTemplate>
<ScrollViewer>
<ItemsPresenter/>
</ScrollViewer>
</ControlTemplate>
</ItemsControl.Template>
</ItemsControl>
关于c# - 滚动条,如果 Items 超过 itemsControl 内部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6161881/