使 ScrollViewer 除非必要否则不滚动
我的 WP7 应用程序中有一个 ScrollViewer,其中包含来自 StackPanel 内的 ItemsControl 的项目。 ItemsControl
可以生成任意数量的项目。
如何让 ScrollViewer
滚动仅当 ItemsControl
生成足够的项目来进行滚动?
没有什么比拖动时滚动的 UI 更糟糕的了,即使当前视口之外没有其他内容可显示!
I have a ScrollViewer
in my WP7 app which contains the items from an ItemsControl
inside a StackPanel
. The ItemsControl
can generate an arbitrary number of items.
How can I make the ScrollViewer
scroll only if there are enough items generated by the ItemsControl
to make scrolling necessary?
There's nothing worse than UIs that scroll when dragged, even though there is nothing else to display outside the current viewport!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有自动/内置的方法可以做到这一点。
但是,假设您的列表项是固定大小的(因此您知道在需要滚动之前可以显示多少个),我会为
VerticalScrollBarVisibility
编写一个转换器并将其绑定到项目数在列表中。There isn't an automatic/built-in way of doing this.
However, assumming that your list items are a fixed size (and so you know how many can be displayed before scrolling is needed) I'd write a converter for the
VerticalScrollBarVisibility
and bind it to the number of items in the list.您尝试过 ScrollBarVisibility = Auto 吗?
Did you try ScrollBarVisibility = Auto?