DataGrid 虚拟化通过 GroupDescriptions 绑定到 ListCollectionView

发布于 2024-12-20 05:49:17 字数 451 浏览 3 评论 0原文

正如标题所示,我有一个绑定到 ListViewCollection 的 WPF DataGrid。数据集很大,但由于行的虚拟化,加载速度非常快。

然而,一旦我添加了一个分组,它就开始加载每一行(我可以从 wpf 调试消息中看到),让我无所事事并吃掉所有的内存。

这里提到了这一点: http://marlongrech.wordpress.com/2008/11 /22/icollectionview-explained/

具体来说,“分组将默认禁用虚拟化支持。因此,对大型数据集进行分组可能非常昂贵,请三思”在这样做之前......”

这解释了很多,但是有人知道如何覆盖该句子中的“默认”位吗?我应该完全使用其他东西吗?

As the title says, I have a WPF DataGrid bound to a ListViewCollection. The dataset is large, but the thing loads very quickly - thanks to virtualization of the rows.

However, as soon as I add a grouping, the thing starts loading every row (I can see from the wpf debug messages), leaving me twiddling my thumbs and eating all the ram.

This is mentioned here: http://marlongrech.wordpress.com/2008/11/22/icollectionview-explained/

Specifically the bit that says "Grouping will disable the Virtualization support by default. So grouping for large data sets could be really expensive, think it twice before doing it…"

Which explains a lot, but does anyone know how to override the "by default" bit in that sentence? Should I be using something else altogether?

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

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

发布评论

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

评论(1

谎言 2024-12-27 05:49:17

框架 4.0 可能没有方便的解决方案,请参阅WPF DataGrid Virtualization with Grouping

您可以展平列表并创建自己的分组(他们在开玩笑吗?) 分组和虚拟化 http://code.msdn.microsoft.com/windowsdesktop/Grouping-and-Virtualization-56e7d3fe

似乎有框架4.5中的解决方案参见:

提高了显示大量分组数据时的性能

当用户界面 (UI) 元素的子集出现时,就会发生 UI 虚拟化
由大量数据项生成,基于哪些项
在屏幕上可见。 VirtualizingPanel 定义了
IsVirtualizingWhenGrouping 启用 UI 的附加属性
分组数据的虚拟化。有关分组的更多信息
数据,请参阅如何:在 XAML 中使用视图对数据进行排序和分组。了解更多
有关虚拟化分组数据的信息,请参阅
IsVirtualizingWhenGrouping 附加属性。 (摘自 WPF 4.5 版的新增功能,不再提供强调文本

There is probably no convenient solution with framework 4.0 See WPF DataGrid Virtualization with Grouping.

You can flatten the list and create your own grouping (are they kidding?) Grouping and Virtualization http://code.msdn.microsoft.com/windowsdesktop/Grouping-and-Virtualization-56e7d3fe

It seems that there is a solution in framework 4.5 see:

Improved performance when displaying large sets of grouped data

UI virtualization occurs when a subset of user interface (UI) elements
are generated from a larger number of data items based on which items
are visible on the screen. The VirtualizingPanel defines the
IsVirtualizingWhenGrouping attached property that enables UI
Virtualization for grouped data. For more information about grouping
data, see How to: Sort and Group Data Using a View in XAML. For more
information about virtualizing grouped data, see the
IsVirtualizingWhenGrouping attached property. (From What's New in WPF Version 4.5 which is no longer availableemphasized text)

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