ItemsControl是一个基础类型,控件本身没有内置滚动条。如果不喜欢ListBox默认的复制样式,只是需要一个简单的可滚动Items Control,可以给ItemsControl的Template加一个ScrollViewer:
<ItemsControl.Template>
<ControlTemplate>
<ScrollViewer x:Name="ScrollViewer" Padding="{TemplateBinding Padding}">
<ItemsPresenter />
</ScrollViewer>
</ControlTemplate>
</ItemsControl.Template>
参考:http://www.silverlightshow.net/items/How-to-add-scrollbars-to-ItemsControl.aspx

本文介绍如何通过在ItemsControl的模板中加入ScrollViewer来实现滚动功能,适用于希望使用简单可滚动ItemsControl而不使用默认ListBox样式的场景。

被折叠的 条评论
为什么被折叠?



