问题
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?
回答1:
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
回答2:
Ensure that you don't modified ListBox
ItemsPanel
that destroys UI virtualization
回答3:
Sheldon_Xiao on has pointed out some references on MSDN that helpfully explain UI virtualizartion
来源:https://stackoverflow.com/questions/13377872/wp7-listbox-how-ui-virtualization-work