Poor scroll performance (15 columns; 300 rows)

Mar 30, 2009 at 1:48 PM
Edited Mar 30, 2009 at 1:50 PM
To be clear, the DataGrid is usable, but the lag is quite apparent and irritating.

While scrolling, I am getting only about 2 or 3 frames per second (Measured by the Perforator tool).  I am intentionally scrolling fast so that on each frame there is competently new set of rows on the screen.  There is 30 rows and 15 columns visible on the screen.

When I sort column, it takes about 1 second for the screen to refresh.

Can someone please try to explain to me why the performance is so bad?  It seems to me that something as simple as this should run at least 10 times faster.

Thank you very much for you reply,

PS: I have 1.7 GHz laptop with WinXP SP3, .NET 3.5 SP1 and DirectX 9.0c.
I am using the folloing code:
public Window1()

DataGrid dataGrid = new DataGrid();

this.Content = dataGrid;

dataGrid.RowHeight = 20;
dataGrid.EnableRowVirtualization = true;
dataGrid.EnableColumnVirtualization = true;

for(int i = 0; i < 15; i++) {
DataGridTextColumn column = new DataGridTextColumn();
column.Header = i.ToString();
column.Binding = new Binding("Data") { Mode = BindingMode.OneWay};
column.Width = 50;

for(int i = 0; i < 300; i++) {
dataGrid.Items.Add(new { Data = i.ToString() });
Apr 1, 2009 at 3:07 PM
I'm experiencing similar issues with about the same size of data as you and a similar functioning machine.  Using the performance profile tools (http://msdn.microsoft.com/en-us/library/aa969767.aspx) I was able to see that a lot of the grid was getting rendered through software instead of hardware, but I am still a bit amazed at how slow things are scrolling.  I wonder if it could have something to do with dynamically building the columns, as I see we are both doing that.
Apr 3, 2009 at 9:17 PM

Can you please send in a repro project?
Apr 3, 2009 at 10:11 PM
To where?
Apr 3, 2009 at 10:34 PM
Edited Apr 3, 2009 at 10:35 PM
Thank you for you reply,

I have uploaded a project file here: http://www.srcf.ucam.org/~ds417/files/PoorScrollPerformance.zip

Best regards,
David Srbecky
May 11, 2009 at 4:20 PM


May 12, 2009 at 5:54 AM
Edited May 12, 2009 at 5:57 AM

How about adding the following properties. PS: Sorry I don't know how to do it in the code.

IsSynchronizedWithCurrentItem = "True"
VirtualizingStackPanel.IsVirtualizing = "True"
VirtualizingStackPanel.VirtualizationMode ="Recycling"




May 13, 2009 at 5:49 PM

PS:  I have the lastest graphics card drivers and Perforator says WPF is using "Hardware render target"

As per your advice, I have tried the following code:
            dataGrid.IsSynchronizedWithCurrentItem = true;
            VirtualizingStackPanel.SetIsVirtualizing(dataGrid, true);
            VirtualizingStackPanel.SetVirtualizationMode(dataGrid, VirtualizationMode.Recycling);
However, it does not make any observable difference.  I think "dataGrid.EnableRowVirtualization = true;" had the same effect.


This is curious - disabling the virtualization does not have any significant effect either.  It does have significant effect on the loading speed, but the scrolling speed is still same (pretty bad).

I am confused.  Why is scrolling so slow even when virtualization is off?  Does WPF have to create/measure/arrange cells even when virtualization is off?

I know that it is probably not your fault, but just a result of WPF design, but could someone please try to explain to me why is the scrolling so slow?  WPF is using DirectX under the covers, right?  So rendering speed should be prety fast.  And just scrolling should not be causing any expensive layout changes.