使 ScrollViewer 除非必要否则不滚动

发布于 2024-12-17 14:35:25 字数 261 浏览 2 评论 0原文

我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

·深蓝 2024-12-24 14:35:26

没有自动/内置的方法可以做到这一点。

但是,假设您的列表项是固定大小的(因此您知道在需要滚动之前可以显示多少个),我会为 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.

浪菊怪哟 2024-12-24 14:35:26

您尝试过 ScrollBarVisibility = Auto 吗?

Did you try ScrollBarVisibility = Auto?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文