I'm using ListBox which has VirtualizingStackPanel
, which is said to support UI virtualizing by default.
However, when I set my listStudent (of type ObservableCollection
, and have 5 Students in it) as ItemsSource
for my Listbox
. Then whenever user scroll to the end, I add another 5 Students to my listStudent (and of course UI is notified). But I see that memory consumed keep increased. There's no different from StackPanel
in term of memory
How UI virtualization work? How to keep memory low when adding new item to listStudent?
virtualization means list do not construct the list items which you have not scroll to yet.
so you can put your test code to item's loaded function or used converter code. you can see whether virtualization works
for example
you can bind a converter to student's name prop and you can log it .then you know when the item create indeed