I always had major performance problems when setting .ItemsSource on a Datagrid to a collection. The method returns fast, but there is a very noticable delay before anything is actually rendered to the screen. Since the Datagrid has the Virtualization modes set, it should be able to handle very larges collections easily. I printed out some debug information in the binded properties of the item collection, to make sure it's not loading the whole collection, but it only accessed the first few items, so I'm sure virtualization is working. And even for small collections, the delay is about the same, so it seems unrelated to actual data loading.
So it's purely the rendering that is causing the slowdown. Most of the times this is caused by having the Datagrid inside a ScrollViewer, or having auto row-height generation, etc. But I ruled all these possible causes out, by giving everything fixed width's, and make sure nothing is set to 'Infinite' or 'Auto'.
After pulling my hair out for weeks, I tried something simple: I switched the Datagrid for a GridView. And to my amazement it does not suffer from the large delay, it paints instantly. Both have exactly the same properties and styling, so I'm trying to understand why the Datagrid was so much slower.
Is there any logical reason why a DataGrid could be slower than a GridView?