I need to display a list of data (100,000~500,000) in DataGrid, in which several columns display images instead of simple data. I have to use "Lazy loading" because loading all the images at once is impossible.
This list should support filtering, sorting and grouping.
My current implementation is to trigger the "fetching images" by the ScrollChanged
event (with the ScrollChangedEventArgs.VerticalOffset
as the startIndex). It works fine if the list has not been grouped. But, if I use CollectionView
to group the data, how can I know the correct data items which need fetching images when the vertical offset of the scroll bar can not be see as a data index anymore?
I was thinking of another solution by using two ViewModels. One is normal ViewModel, and one is GroupedViewMode. And I can display the grouped data in DataGrid like this:
public class GroupedData{
public string ColumnName{get;set;}
public bool Expanded{get;set;}
public List<Data> List{get;set;}
}
And, then, I can somehow get the data which need fetching images when the scrollbar value is changing. But, here is another question... how can I bind this data format in a DataGrid
?
=========================
IsVirtualizingWhenGrouping
is good, but it cannot fully solve my problem, I still need to load all the data in the memory in the first place. The data may be up to Gigabytes, it is memory consuming. So my current solution is to load all the data with image excluded to support sorting, grouping etc, then load images when needed.