Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ListView Update Extremely Slow When Grouping Is Used

Tags:

wpf

From my understanding, the default ItemsPanel for ListView is VirtualizingStackPanel. When I create a GroupStyle for my list view, the refresh rate is terrible. Based on comments in this post

WPF ListView Very Slow Performance - Why? (ElementHost, or Other Reason?)

GroupStyle overrides the default VirtualStackPanel with StackPanel. I have explicitly declared a VirutalzingStackPanel as my ListView's ItemsPanel, but performance is still bad. Why is grouping so slow? More than likely there is something going on with grouping I don't understand.

like image 292
Bubbles Avatar asked Dec 05 '25 11:12

Bubbles


1 Answers

As the author of the post below mentions

In a normal WPF ItemsControl that virtualizes, such as ListBox or ListView, virtualization turns off when you turn grouping on. This sample shows how to achieve the same visual look of grouping and much of the same API while still having virtualization.

Have a look at this solution developed in the sample project. However, not an easy or straight forward method at all.

Grouping and Virtualization

Remember that this method is suggested for .NET 4.0 and earlier. I believe there are new methods introduced in the .NET 4.5 which deal with this situation such as VirtualizingPanel.IsVirtualizingWhenGrouping property. However I haven't tested this since I don't have an access to .NET 4.5 atm.

VirtualizingPanel.IsVirtualizingWhenGrouping Attached Property

Gets or sets a value that indicates whether this VirtualizingPanel virtualizes the items in its collection when it displays groups.

like image 115
Mehrad Avatar answered Dec 07 '25 04:12

Mehrad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!