Skip to content

VirtualizingStackPanel

If you use ItemsControl elements in your XAML UI, such as a ListBox or ComboBox, you should also use a VirtualizingStackPanel.

With a VirtualizingStackPanel, the XAML Runtime renders only the elements in the items control that are currently visible. By using a VirtualizingStackPanel, you can help improve load time for the items in the items control.

To use a VirtualizingStackPanel

  1. Add the VirtualizingStackPanel.IsVirtualizing attached property to the ItemsControl element.
  2. Set the attached property value to True.

To reuse item containers after they are no longer visible on the screen

  1. Add the VirtualizingStackPanel.VirtualizationMode attached property to the UI element.
  2. Set the attached property value to Recycling.

The following example code shows a list box element that uses a VirtualizingStackPanel.

<Listbox VirtualizingStackPanel.IsVirtualizing="True" Height="150" Width="200" x:Name="listbox">

Feedback and Knowledge Base