7

I have a window using a WPF ListView/GridView bound to an ObservableCollection. The performance is utterly horrific. The application chokes trying to load 300-400 items and CPU usage spikes each time an item is added/removed/modified. Profiling doesn't reveal anything obvious.

Anyone have any suggestions?

6 Answers6

9

Check these properties out:

VirtualizingStackPanel.IsVirtualizing="True"
VirtualizingStackPanel.VirtualizationMode="Recycling"
ScrollViewer.IsDeferredScrollingEnabled="True"
redjackwong
  • 1,568
  • 2
  • 12
  • 14
5

You need to virtualize your ListView's ItemSource as explained in this article: WPF: Data Virtualization on CodeProject by Paul McClean

Soni Ali
  • 18,464
  • 16
  • 44
  • 53
2

First guess, are you making use of complex data templates for each ListViewItem? This might be anything from lots of images, to (old) BitmapEffects, to even lazy-loaded properties that fetch data on demand from a database (which may cause you to perform many db calls to render each visual, depending on how your data model works).

Second guess, is the list itself able to run its load/add/modified/removed routines quickly (meaning the problem occurs when rendering the data), or does the list itself do those jobs slowly (indicating the list is having some kind of issue).

Adrian
  • 1,338
  • 8
  • 17
  • The DataTemplate being used contains a single TextBlock. –  Feb 20 '09 at 20:38
  • Can you share a bit more of your code that reproduces your issue? Maybe a simple new solution that runs the bare minimum to cause it? – Adrian Feb 20 '09 at 21:27
1

have you tried virtualization as recommended in this question??

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

Community
  • 1
  • 1
DouglasH
  • 1,216
  • 9
  • 12
  • This will only help if you are explicitly setting the ItemsPanel property to use something other than the default, which is already a VirtualizingStackPanel. – Adrian Feb 20 '09 at 22:32
1

And the obvious one, make sure you have upgraded to .net 3.5 SP1, there were a lot of performance gains there.

Also it may be worth looking into the WPF datagridview control as a lot of the performance work in .net 3.5 SP1 were so the datagridview would have good performance on large datasets.

http://wpf.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=25047

Jake Ginnivan
  • 2,112
  • 16
  • 20
0

I had similar problems. Setting MaxHeight to a value larger than the ListView's actual height solved it instantly for me, thanks to this answer here, but I still fail to understand how it worked.

Simon Voggeneder
  • 377
  • 1
  • 7
  • 16