Prince Ashitaka
Prince Ashitaka

Reputation: 8773

What is the Disadvantage of VirtualizingStackPanel?

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?

Upvotes: 4

Views: 1084

Answers (1)

ChrisF
ChrisF

Reputation: 137148

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.

Upvotes: 3

Related Questions