Home > Net >  WPF MahApps Listview performances
WPF MahApps Listview performances

Time:10-10

I populate a ListView with a simple List<T> source. I also use grouping on the ListView (using default view GroupDescriptions) and sorting (using ListView items SortDescriptions).

If I display few items, no issue, but when I load 10 000 items the application freeze and when loading is finished it becomes very difficult to scroll.

On some other topics I've seen that I have to force virtualization with MahApps listview using:

<Style BasedOn="{StaticResource MahApps.Styles.ListView.Virtualized}" TargetType="ListView" />

And I guess I've activated it correctly because CanContenScroll is True when I check my ListView property (and it wasn't before the style definition). Nevertheless, the display is still very slow.

Is there something I miss to fully activate the virtualization ? Should I use another collection type instead of List<T> ?

CodePudding user response:

Based on @mm8 suggestion to test without MahApps, I had to set explicitly in ListView definition the content of MahApps.Styles.ListView.Virtualized :

<ListView ScrollViewer.CanContentScroll="True" ScrollViewer.IsDeferredScrollingEnabled="True" 
VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.IsVirtualizingWhenGrouping="True">

And then it was working well, so I've enabled again MahApps styles letting the explicit definition in the ListView (and not using global style as previously) and it is still working like a charm.

So I don't know why, but using the global styling wasn't working. Maybe something overwrite it elsewhere.

  • Related