Hi there,
I've been trying to speed up the response of a DataGrid I have inside my application and I seem to have hit a brick wall. The problem is that the performance of the control is unacceptable in its current state in my application. I have bound a small DataTable to it (say, 100 rows and 8 columns), and the scrolling performance is pretty brutal. It seems to lag the mouse by maybe 0.2s. Also, when I try to maximize the window, I get a big black visible patch on the screen before the window maximizes and a noticeable delay. Switching the control to a ListBox immediately fixes the problem (although my ListBox is displaying much, much less information).
The worst case scenario is when I set it up as follows (my desired implementation!): a left pane and a right pane, with the left pane containing a "parent" list box and the right pane controlling the "detail" DataGrid. The "detail" data is the same as the case above where the only control is a DataGrid, it's just filtered through a DataRelation in the table when you select a ListBox item on the left pane. I find that there's almost a half-second delay between when I click on a ListBox item in the left pane and when the corresponding data appears within the DataGrid detail view on the right. Again, if I switch the DataGrid to a ListBox, the response is almost instantaneous.
If I use the keyboard to switch the ListBox item on the left pane, and just tap up-down-up-down etc., I end up getting this whole delayed cascade of switches on the right pane where it will continue to switch for many seconds after I've stopped hitting the keys. I've tried all sorts of combinations of VirtualizingStackPanel settings (Recycling mode and Virtualization On), but nothing seems to fix the problem. I've also tried the EnableColumnVirtualization and EnableRowVirtualization to True. Doesn't seem to help at all.
Running the app through the WPF Performance Suite shows a large Update (Measure/Layout) component being used by the DataGrid, but I feel as if I'm not asking too much to display a couple of hundred records. Also, the performance doesn't seem to decrease very linearly as I move into the thousands of records area, so I feel like there's something fundamental I'm missing.
Here are the final questions:
1) Is the layout of the DataGrid the problem? I'm just trying to show too much information?
2) If so, is there anything I can do to fix this other than showing fewer records at a time?
3) If not, what events can I time out to narrow down where the lag is taking place?
Thanks for any help you can give me!