hi here i'm trying to display some buttons in a stack panel horizontally an dit exceeds the screen visible area what i want is, to display what are the items are currently displayed now on the screen in ta text box. How can i do this (for this i'm using virtualizingStackPanel but i dont know how to use it exactly)

This is my code

<ListBox Name="lbox" Height ="80" virtualizingStackPanel.IsVirtualizing ="True">

<ListBoxItem Name="lbitem" HorizontalAlignment="Center">

<StackPanel width="Auto" Orientation ="Horizontal" Name="lbStackpanel" HorizontalAlignment="Center" Background="Black" virtualizingStackPanel.IsVirtualizing ="True"virtualizingStackPanel.IsVirtualizing ="True">

























Re: Windows Presentation Foundation (WPF) virtualizingStackPanel

Henry Hahn - MSFT

You need to use a DataSource to use the VirtualizationStackPanel. See for info.

Re: Windows Presentation Foundation (WPF) virtualizingStackPanel

Marlon Grech


can you please tell me what is the difference between




All I know is that if you use the first one it is much faster.... (I didn't try it yet....)


Re: Windows Presentation Foundation (WPF) virtualizingStackPanel



When a panel is virtualized it means that only the element visible are created. The rest aren't displayed.

For example, create a listbox displaying images bound to a folder holding 100,000 images. It would take a long time for the listbox to load. If you use a virtualize panel, then only the visible images will get created in the UI. When you scroll down, the currently visible will get destroyed and the new visible image will get loaded onto the UI.

There is only one panel that support virtualization and it is the VirtualizingStackPanel. If you need a wrap panel that virtualize, you will have to write your own.

Hope this helps.


Re: Windows Presentation Foundation (WPF) virtualizingStackPanel

Marlon Grech


Thanks this is very helpful... just another small question...

Would you use the VirtualizingStackPanel even for a small amount of items