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
- Add the VirtualizingStackPanel.IsVirtualizing attached property to the ItemsControl element.
- Set the attached property value to True.
To reuse item containers after they are no longer visible on the screen
- Add the VirtualizingStackPanel.VirtualizationMode attached property to the UI element.
- 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">