缓慢而Stuttery WPF网格滚动时,大量的数据装载(40列,2000行)网格、缓慢、数据、Stuttery

2023-09-04 01:21:15 作者:一路秒杀:ㄣ

在简单地说,我们是无法满载时的纯数据重数量从任何类型的WPF网格/项的控制得到合理的滚动性能。

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.

我们已经创建了使用DevEx preSS WPF电网静态独立的原型,并在这里上传吧:

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

http://jump.fm/QOTDL

我们也试着与Infragistics的和Xceed电网,问题是一样的。

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

这似乎是WPF根本无法应付相当大的数据网格显示大量的数据,尽可能提供流畅的用户体验去。即使没有任何形式的数据绑定,只需提供静态数据(〜40列宽,2000行),带滚动如蜗牛。在最低水平,分析器似乎表明的,除了大量的垃圾收集的测量发生的历史过量可能是不规则口吃的原因。

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.

的code在原型中可以很容易地替换为其它网格来工作。如果有任何人能够产生在给定的情况下平滑滚动体验的尤其的在数据分组后在多个级别,并且密集的情况下,请告诉我们,我们会很感兴趣听到你。

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.

其他详细信息:

我们正在建立我们的2000的对象(与〜每40属性),并将其分配给网格的DataSource属性。

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

我们的每一个对象都被重新$ P $:

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;

这将导致显示此信息的数据网格。我们所做的字体较小(10px的,在用户的请求),并自动调整和组的列。结果最后应该与此类似:

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:

https://m.xsw88.com/allimgs/daicuo/20230904/6310.png

和滚动很stuttery /慢。让我们知道,如果你有什么想法。

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

推荐答案

数据网格随.NET 40的作品就好了远远超过这一点。测试200列和50K行(搭配INT32,双,字符串和自定义类的显示器。

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.

有标志的启用行和列virtualizations。但请记住,如果你正在做的分组,杀死行虚拟化。

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.