WPF DataGrid performance without virtualization

I only have a question about Microsofts PresentationFramework's DataGrid :

I have an ObservableCollection<TestModel> . TestModel is a simple class with 20 Int properties ... nothing more. In my test, there are 50 entries in my ObservableCollection . So in general, I got 1000 cells (20 * 50). All these cells are displayed immediately, so virtualization is actually not possible.

This is my grid:

 <DataGrid AutoGenerateColumns="true" RowHeight="20" ItemsSource="{Binding DataGridModelSource}"/> 

In my opinion, 1000 cells for rendering are not very many ... although it depends on the system on which I run this test, from about 1 to 3 seconds to display these 1000 cells. That's quite a lot, right?

I did the same test with some custom DataGrids like the one that C1, Infragistics, Mindscape or DX had, and the time to render these 1000 cells was reduced to about 100 ms with all these grids.

So what's up with Microsoft DataGrid ? Is there a way to improve performance? Did I miss something?

+6
source share
1 answer

Use BindingList ( https://msdn.microsoft.com/en-us/library/ms132679%28v=vs.110%29.aspx ) instead of ObservableCollection. The problem is that you have to do grouping, sorting, etc. Alone, but it should be faster.

Other things you could do is simplify styles for your current theme. You can use https://wpfinspector.codeplex.com/ to find something (even if this is the default theme for Windows)

0
source

Source: https://habr.com/ru/post/970759/


All Articles