views:

42

answers:

1

What is/are the main disadvantage of VirtualizingStackPanel? If it doesn't have any, then why it is not made as a default panel behavior/template in ItemsControl?

+3  A: 

The MSDN page on the VirtualizingStackPanel Class has the following statements:

The word "virtualize" refers to a technique by which a subset of user interface (UI) elements are generated from a larger number of data items based on which items are visible on-screen.

and

Virtualization in a StackPanel only occurs when the items control contained in the panel creates its own item containers.

and

VirtualizingStackPanel is the default items host for the ListBox element.

From this it looks like for the "normal" use of a StackPanel as a host for buttons, text blocks etc. virtualisation wouldn't offer any advantages or might even impose a performance overhead. When used in a ListBox virtualisation does have benefits as a) item containers are created by the items control and b) there are likely to be more elements in the list than can be shown on the screen at any one time.

ChrisF
So in the case of creating a custom panel without modifying the container style for items. There is no special advantage. I had a scenario of generating 20K items. I tried displaying them in virtualized item control the fact is displaying it in Grid panel is much faster. Thanks for the precise information. :)
Avatar
`VirtualizingStackPanel.IsVirtualizing="True"` `VirtualizingStackPanel.VirtualizationMode="Recycling"` Does a great miracle in ListBox. @ChrisF Thanks again. You rock :)
Avatar