i am using a datagrid to display a datatable which contains ~50 rows. For some reason the rendering of the grid is very slow, i takes ~ 2sec to display the grid with the data. If I use a ListBox or a ListView for example the rendering is way faster, which means no delay at all. The datatable i want to display has 20 columns, but also if i want to display only one column it has no effect on the rendering performance.
That's the code i am using to display the grid:
<DataGrid ItemsSource="{Binding Data}" AutoGenerateColumns="True" />
if I set autogeneratecolumns to false (the grid renders the rows but no columns), the grid still needs ~2sec to render
<DataGrid ItemsSource="{Binding Data}" AutoGenerateColumns="False" />
if i use a listbox instead it has no delay at all (but i need to write a generic template to display all the columns), also ListView has no delays at all
<ListBox ItemsSource="{Binding Data}"/>
I have no idea why the grid is that slow. I have also tried to set VirtualizingPanel.IsVirtualizing="True" but it had no effect on performance.
Any ideas?
KR Manuel
ALL DataGrid's are horrendously slow (even the ones you pay for). You need to turn on virtualization. VirtualizingStackPanel.IsVirtualizing = true
as well as VirtualizingStackPanel.VirtualizationMode = recycling
. If you have a lot of columns, or start to do templates, it'll slow to a crawl again. Nothing you can do about that really. I've tried every DataGrid out there (syncfusion, infragistics, etc). They are all very slow.