WPF-使用 ContentPresenter 或 VirtualizingStackPanel 作为 ListBox ControlTemplate 中的 itemshost 之间是否存在性能差异?

发布于 2024-09-14 19:34:10 字数 20 浏览 1 评论 0原文

这个问题几乎是不言自明的。

The question is pretty much self-explanatory.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

醉态萌生 2024-09-21 19:34:10

是的,有。 VirtualizingStackPanel 优化了项目的显示 - 它仅创建和保存可见项目 - 从而提供了更好的性能。

使用另一个面板可以为您提供更多的样式和滚动可能性,但如果您有数百或数千个条目,则可能会出现问题。

顺便说一句,如果将 CanContentScroll 属性设置为 false,则即使 VirtualizingStackPanel 也会生成所有项目以提供更平滑的滚动 - 默认为滚动从一个项目到下一个项目。

Yes, there is. The VirtualizingStackPanel optimizes the display of the items - it only creates and holds the visible items - and thus provides a better performance.

Using another panel can give you extended possibilities in styling and scrolling, but it might be problematic if you have hundrets or thousands of entries.

BTW, if you set the CanContentScroll property to false even the VirtualizingStackPanel will generate all items in order to provide smoother scrolling - the default is to scroll from on item to the next.

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