WPFK WPFK - 1 year ago 142
C# Question

Improve WPF DataGrid performance

In my

.NET 3.5
Application, I have a
which will be populated with 500 columns and 50 rows.
The performance of App is very very poor in scrolling, or when I do
or in selecting rows.

Actually App will take around 20 sec to Update Layout.
event will trigger after 20 sec.

If I reduce the columns to 50 or less, App will be very responsive. As per my findings performance is directly related to column count.

How do I improve the

Answer Source

There are a few options you can turn on to help you on your DataGrid object

EnableColumnVirtualization = true
EnableRowVirtualization = true

These two are the main ones I think might help. Next try making your binding async

ItemsSource="{Binding MyStuff, IsAsync=True}"

And lastly, I've heard that setting a maximum height and width can help even if it above the max screen size, but I didn't notice a difference myself (claim had to do with auto size measuring)


Also never put a DataGrid in a ScrollViewer, because you will essentially lose virtualization. Let me know if this helps!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download