user67807
user67807

Reputation:

WPF listview / gridview performance horrible, suggestions

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?

Upvotes: 8

Views: 11856

Answers (6)

Simon Voggeneder
Simon Voggeneder

Reputation: 387

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.

Upvotes: 0

Soni Ali
Soni Ali

Reputation: 19010

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

Upvotes: 5

Jake Ginnivan
Jake Ginnivan

Reputation: 2142

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

Upvotes: 1

redjackwong
redjackwong

Reputation: 1568

Check these properties out:

VirtualizingStackPanel.IsVirtualizing="True"
VirtualizingStackPanel.VirtualizationMode="Recycling"
ScrollViewer.IsDeferredScrollingEnabled="True"

Upvotes: 9

DouglasH
DouglasH

Reputation: 1246

have you tried virtualization as recommended in this question??

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

Upvotes: 1

Adrian
Adrian

Reputation: 1358

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).

Upvotes: 3

Related Questions