WPF DataGrid virtualization not working properly?

I have a DataGrid that has a DataTable set as its ItemSource. The DataTable contains 24 columns and ~ 1600 rows (in fact, I will have to load more rows later, but for now it's pretty complicated).

Although virtualizing active columns and rows, the DataGrid takes about 30 seconds to display these 1600 rows. After that, vertical scrolling works fine, horizontally lags, although you expect it to be the other way around.

If I run the memory profiler, I can verify that most of the memory used by the application comes from DataGridCells, Borders, ContentPresenters, and Textblocks. For me, this means that the grid does not virtualize its rows properly.

Can anyone confirm that there are problems with DataGrid virtualization? Or is there some kind of notorious trap in implementing this control?

We look forward to any suggestions / suggestions. Thank:)

+5
source share
2 answers

I solved the problem. My DataGrid sat inside a ScrollViewer, in which it was stretched endlessly. Therefore, it was deceived to think that everything is visible, so he will not virtualize his objects. I removed the ScrollViewer (the DataGrid has scrollbars anyway) and now it works flawlessly.

+5
source

Hm, well, I don’t know why, but obviously I have to add some kind of glue text to post the answer here. Perhaps this SO answer will help you.

Edit

. 1.6k + DataGrid? , .

+1

All Articles