简体   繁体   English

WP8 ListBox无需滚动

[英]WP8 ListBox without scrolling

In a WP8 app I want to use an "Item Container" without scrolling. 在WP8应用程序中,我想使用“项目容器”而不滚动。 The reason is that the app dynamically adds and removes items so that the size of that list changes. 原因是该应用程序动态添加和删除项目,以便该列表的大小发生变化。 I want the control, that holds the items to adjust its height depending on the number of items. 我想要一个控件,该控件可以根据项目数来调整其高度。 ListBox so far provides me with all those requirements. 到目前为止,ListBox为我提供了所有这些要求。 However, ListBox itself contains a scroll viewer. 但是,ListBox本身包含一个滚动查看器。 So when I want to scroll up or down on the page I need to make sure that I don't touch the ListBox as this will just scroll the ListBox's items. 因此,当我想在页面上向上或向下滚动时,我需要确保不要触摸ListBox,因为这只会滚动ListBox的项目。 The reason I'm using ListBox instead of a StackPanel or Grid is that the XAML code binds to an observable collection via ItemsSource. 我使用ListBox而不是StackPanel或Grid的原因是XAML代码通过ItemsSource绑定到了一个可观察的集合。 I don't want to loose that binding. 我不想失去这种约束。

Question: Is there any way to disable scrolling in a ListBox? 问题:有什么方法可以禁用在列表框中滚动? Is there any alternative Item Container (3rd party maybe or in the framework)? 是否有其他替代项容器(可能是第三方,也可能是在框架中)?

to disable ListBox's scrolling use ScrollViewer.HorizontalScrollBarVisibility=Disabled and ScrollViewer.VerticalScrollBarVisibility=Disabled. 要禁用ListBox的滚动,请使用ScrollViewer.Horizo​​ntalScrollBarVisibility = Disabled和ScrollViewer.VerticalScrollBarVisibility = Disabled。

You can add any other scroll viewer to your page using this your list box wont scroll. 您可以使用此列表框不会滚动的方式将其他任何滚动查看器添加到页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM