Slow and Stuttery WPF Grid Scrolling when loaded w

2019-04-08 15:45发布

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.

1条回答
戒情不戒烟
2楼-- · 2019-04-08 16:21

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.

查看更多
登录 后发表回答