Does anyone know of a ListView implementation that support UI Virtualization when grouping is enabled? By default the VirtualizingStackPanel is disabled when grouping is setup.
It seems that Microsoft is not going to implement this within v4.0 of the .NET Framework so I am look for alternate solutions.
I have located a sample at Grouping and Virtualization MSDN Code Sample that converts the grouped ListView into a flat list which supports virtualization. However I can't work out how to imitate the expanding actions of the headers.
One option is to take a look a Bea Stollniz's series on improving a TreeView's performance: Part 1, Part 2, and Part 3. While what she does is more geared to TreeViews, which don't have any virtualization because they group by default, the lessons learned could definitely be applied to a custom ListView that has virtualizing groups. In fact, in part 3, she uses a ListBox as her base to create the virtualizing tree, which is a good start for virtualized grouping as well. Obviously displaying the items like in a TreeView has some diffrences, such as selection of the group nodes, from a ListView with grouping, but that could be fixed by catching the SelectionChanged.
wpf/.net 4.5 now supports this https://msdn.microsoft.com/en-us/library/system.windows.controls.virtualizingpanel.isvirtualizingwhengrouping(v=vs.110).aspx
If you are still targeting 4.0 you can set it with reflection so at least some users can get the benefit.
I hope its not too much off topic but I had recently a similar problem. As stated above it is only .NET 4.0 issue. I would even agree that in most cases with combo box you should not normally need virtualization because it should not have that many items and if there is need for grouping then some kind of master-detail solution should be implemented. But there might be some gray areas.
The link provided by Luke about Grouping and Virtualization on MSDN helped me a lot. In my case that was the only approach which I was able to come up or find anywhere that is in a direction i need. It does not support all functionality from ListViewCollection. I had to override few methods otherwise selection of items would not work correctly. There are obviously more work to do.
So here is an updated solution of FlatGroupListCollectionView from here :
XAML part stays as it is in sample code. View model stays as it is as well which means using FlatGroupListCollectionView and set up GroupDescriptions.
I prefer this solution because it separates grouping logic from my list of data in view model. Other solution would be to implement support of grouping on original list of items in view model which means somehow identify headers. For a one time usage it should be fine but the collection might need to be recreated for a purpose of different or no grouping which is not so nice.