WPF ListView SelectAll performance when group enabled

元常 庞 1 Reputation point
2022-11-07T02:18:42.86+00:00

The listview loads about 50k rows of data, i'm sure Virtualizing is enabled, the listview loads without any issue. SelectAll operation completed really quick if group is not enabled, but the performance get very bad when grouping is enabled.

After some investigation, i found the cause of the issue is by below code
method ContainerFromIndex in ItemContainerGenerator.cs(wpf source) , is there any way to improve the performance in this scenario?

if (IsGrouping)
{
int n;
subIndex = index;
for (index=0, n=ItemsInternal.Count; index < n; ++index)
{
CollectionViewGroup group = ItemsInternal[index] as CollectionViewGroup;
int size = (group == null) ? 1 : group.ItemCount;

                if (subIndex < size)  
                    break;  
                else  
                    subIndex -= size;  
            }  
        }
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,676 questions
{count} votes