加载大量数据(40 列,2000 行)时 WPF 网格滚动缓慢且卡顿

发布于 2024-10-01 11:56:16 字数 1337 浏览 2 评论 0原文

简而言之,当加载大量纯数据时,我们无法从任何类型的 WPF 网格/项目控件获得合理的滚动性能。

我们使用 DevExpress WPF 网格创建了一个静态独立原型,并将其上传到此处:

http://jump.fm/QOTDL

我们也尝试过 Infragistics 和 Xceed 网格,问题是一样的。

就提供流畅的用户体验而言,WPF 似乎根本无法应对显示大量数据的相当大的数据网格。即使没有任何类型的数据绑定,仅提供静态数据(约 40 列宽,2000 行),也会使滚动变得缓慢。在最低级别,分析器似乎表明除了大量垃圾收集之外还发生了过量的“测量”,这可能是不规则口吃的原因。

原型中的代码可以轻松替换以与其他网格一起使用。如果有人能够在给定的场景中产生平滑的滚动体验,特别是在数据按多个级别分组且密集的情况下,请告诉我们,我们对此非常感兴趣收到你的来信。

其他详细信息

我们正在创建 2000 个对象(每个对象大约有 40 个属性),并将它们分配给网格的数据源属性。

我们的每个对象都表示为类似于下面的类:

public class RowViewModel
{
    public double AskAsw { get; set; }
    public string AskBmkName { get; set; }
    public double AskBmkPrice { get; set; }
    public double AskBmkSprd { get; set; }
    ... and so on
}

这些对象被创建并添加到集合/列表中,如下所示:

        for (int i = 1; i < 2000; i++)
        {
            _rowViewModels.Add(new RowViewModel(i));
        }

然后绑定到数据网格。非常简单:

        gridControl.DataSource = _rowViewModels;

这会导致数据网格显示此信息。我们将字体变小(10px,根据用户的要求),并自动调整大小和对列进行分组。结果最终看起来类似于:

http://i54.tinypic.com/21jt11t.png

并且滚动非常断断续续/缓慢。如果您有任何想法,请告诉我们。

In a nutshell we're unable to get reasonable scrolling performance from any kind of WPF grid/items control when loaded with heavy amounts of pure data.

We've created a static independent prototype using the DevExpress WPF grid and uploaded it here:

http://jump.fm/QOTDL

We've also tried with the Infragistics and Xceed grid, and the problem is the same.

It seems like WPF simply cannot cope with reasonably large data grids displaying lots of data as far as providing a smooth user experience goes. Even without any kind of databinding, simply providing static data (~40 columns wide, 2000 rows), brings the scrolling to a crawl. At the lowest levels, the profiler seems to indicate an excessive amount of "Measure" occuring in addition to lots of garbage collection which could be the cause of the irregular stutter.

The code in the prototype can easily be replaced to work with other grids. If anyone out there is able to produce a smooth scrolling experience in the scenario given especially in cases where data is grouped at multiple levels and is densely packed, please let us know, we'd be very interested in hearing from you.

Additional details:

We're creating our 2000 objects (with ~40 properties each), and assigning them to the grid's datasource property.

Each of our objects is represented as a class similar to below:

public class RowViewModel
{
    public double AskAsw { get; set; }
    public string AskBmkName { get; set; }
    public double AskBmkPrice { get; set; }
    public double AskBmkSprd { get; set; }
    ... and so on
}

These are created and are added to a collection/list like so:

        for (int i = 1; i < 2000; i++)
        {
            _rowViewModels.Add(new RowViewModel(i));
        }

And then bound to the datagrid. Very straightforward:

        gridControl.DataSource = _rowViewModels;

This results in a datagrid displaying this information. We made the font smaller (10px, at user's request), and autosize and group the columns. The result ends up looking similar to this:

http://i54.tinypic.com/21jt11t.png

And scrolling is very stuttery/slow. Let us know if you have any thoughts.

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

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

发布评论

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

评论(1

最笨的告白 2024-10-08 11:56:16

.NET 40 附带的数据网格可以很好地解决这个问题。使用 200 列和 50K 行进行了测试(混合了 int32、double、字符串和自定义类显示。

有一些标志可以打开行和列虚拟化。但请记住,如果您正在进行分组,则会杀死行虚拟化。

我通过以下方式解决了这个问题使用我自己的向下钻取 - 两个表 - 用户控件来获得分组功能,虽然不是很好,但足以满足我的需求。

The Data Grid that comes with .NET 40 works just fine for well over that. Tested with 200 columns and 50K rows (mix of int32, double, strings and custom class displays.

There are flags to turn on row and column virtualizations. Remember though that if you are doing grouping, that kills row virtualization.

I get around that by using my own drill down - two table - user control to get grouping functionality. Not great but sufficient for my needs.

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