如何让一系列 IEnumerable 对象看起来像 Windows Phone 7 中的一个大堆栈面板?
对于这个例子,我有一个 IList<>包含一组也是列表的对象。例如,一个联赛由一组球队组成,而这些球队又由球员组成。我想要的是一个只有一个滚动条的列表。
我尝试过嵌套的 ListBox 控件,但最终变成了一堆表现可怕的多个滚动条。滚动功能很糟糕,它似乎隐藏了球队球员列表的底部。
任何帮助都会很棒!
I have, for this example, an IList<> that contains a set of objects that are also lists. for example, a league consists of a set of teams and those teams are comprised of players. What I want is a single list that has one scrollbar.
I have tried nested ListBox controls but that ends up being a stack of multiple scrollbars that acts horrible. Scrolling is just bad and it seems to hide the bottom of the team's player list.
Any help would be great!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不使用
ItemsControl
而不是ListBox
?ListBox
提供选择,如果您不需要它,ItemsControl
是 更轻量且加载速度更快。此外,通过ItemsControl
,您可以完全控制托管项目的元素。这样,您就可以省略ScrollViewer
。要渲染您的项目,请尝试以下操作:
Rather than a
ListBox
, why not use anItemsControl
? AListBox
provides selection, if you do not need this, anItemsControl
is more lightweight and will load faster. Also, with anItemsControl
you have full control over the elements that host your items. This way, you can omit theScrollViewer
.To render your items, try the following:
您可以非常轻松地禁用列表框的滚动条。只需将
ScrollViewer.VerticalScrollBarVisibility="Disabled"
添加到内部 ListBox 的 XAML 属性即可。You can disable scrollbars for a ListBox quite easily. Just add
ScrollViewer.VerticalScrollBarVisibility="Disabled"
to the XAML attributes for the inner ListBox.