WP7 Listbox how UI virtualization work

故事扮演 提交于 2019-12-11 04:37:55

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!