Tips and tricks to improve datagrid's performance?

May 8, 2009 at 6:59 AM


I use datagrid to display arbitrary sized two dimensional arrays. Data in arrays can be in different formats so I use a column derived from the DataGridTemplateColumn to select proper template for each cell. Because of the arrays I can't use AutoGenerateColumns="True" and since arrays are arbitrary sized I can't configure columns in XAML but add them dynamically on the fly. I'm also using Vincent Sibal's implementation for frozen rows so I can't use virtualization.


This all works fine with smaller arrays (e.g 5x5) but with larger (e.g 30x30) I start to see some serious performance problems. Updating grid takes 4-6 seconds which is annoying since I have to change displayed arrays very often. Running the program with profiler seems to indicate that most of the time is spent measuring cells and adding new item containers.

Is there anything I could try to improve performance atleast a bit?



Hannu Pousi