I am using a DataGrid
with CellEditingTemplates
. As ItemsSource
a data virtualized collection is used (the AlphaChiTech solution), which only fetches pages of a size of 100 items at a time on demand.
It works great until a cell is double clicked into the editing form, then the VirtualizingStackPanel
requests all items one after another. Of course as a side effect all pages are requested eventually.
Is there a way to workaround this issue?
Edit:
I found a workaround, which might help people in my situation:
Eventually I observed that the VirtualizingStackPanel did not request all items under the condition that the row height stays the same after switching to the editing form. Before the workaround my editing form was slightly higher.
Now I set up the MinHeight of the controls in the cells (both normal and editing) in such a way that with switching to the editing form the height does not change.
Unfortunately this works only under certain conditions. There are cases in which it will not work:
Using
RowDetailsTemplate
. As soon as it is visible the virtualization is broken. I assume that the row details belong to the row its self, so the row height increases again.Raising the Reset event oft the Collection respectivelly the CollectionView. In my experience this is generally the killer for data virtulization with
DataGrids
.Decraesing the
Count
of the collection (This is also without throwing the Reset event a problem).
It is interesting that increasing the Count
of the collection did work. But I had to enhance the capabilities of the AlphaChiTech (fortunatly the sources are on github), because there is no way there to change the Count
without raising the Reset event out-of-the-box (atleast I did not found). Also the DataGrid's
items have to be refreshed immediatly afterwards or else an exception is thrown stating that the ItemsControl
and the collection do have an inconsistend state.
The row details are optional to me, but deleting items without breaking the data virtualization is crucial. Thus, the problem still remains. My workaround will most likely help people with collections of fixed size, but unfortunately not myself.