How do I make this snippet virtualized?
According to the MSDN forums, All databound listboxes are virtualized
You can check what's going on in your app using Snoop - Mouse over your listbox (or one of the items) and look at the properties. One of them is VirtualizingStackPanel.IsVirtualizing
- it will be checked if the list is virtualized, and unchecked if not
Your code sample does not virtualize because you are forcing the use of a StackPanel
. You have to use a VirtualizingStackPanel
.
It is an essential tool for the wpf developer as it has a couple of other really handy features as well
To know if it is virtualized you can simply add 10K dummy entries to the collection and see how fast the loading happens as well as how fast the vertical scroll works which will clearly tell a big difference.
I guess you need to change your StackPanel
in the control template to VirtualizingStackPanel
.