Justin
Justin

Reputation: 2479

WPF- Is there a performance difference between using a ContentPresenter or a VirtualizingStackPanel as the itemshost in a ListBox ControlTemplate?

The question is pretty much self-explanatory.

Upvotes: 1

Views: 694

Answers (1)

AxelEckenberger
AxelEckenberger

Reputation: 16926

Yes, there is. The VirtualizingStackPanel optimizes the display of the items - it only creates and holds the visible items - and thus provides a better performance.

Using another panel can give you extended possibilities in styling and scrolling, but it might be problematic if you have hundrets or thousands of entries.

BTW, if you set the CanContentScroll property to false even the VirtualizingStackPanel will generate all items in order to provide smoother scrolling - the default is to scroll from on item to the next.

Upvotes: 1

Related Questions