简体   繁体   English

WP7 Listbox UI虚拟化如何工作

[英]WP7 Listbox how UI virtualization work

I'm using ListBox which has VirtualizingStackPanel , which is said to support UI virtualizing by default. 我正在使用具有VirtualizingStackPanel ListBox,据说该列表默认情况下支持UI虚拟化。

However, when I set my listStudent (of type ObservableCollection , and have 5 Students in it) as ItemsSource for my Listbox . 但是,当我将listStudent (类型为ObservableCollection ,并且有5个Student )设置为Listbox ItemsSource Then whenever user scroll to the end, I add another 5 Students to my listStudent (and of course UI is notified). 然后,每当用户滚动到末尾时,我就会在listStudent中再添加5个学生(当然会通知UI)。 But I see that memory consumed keep increased. 但是我看到消耗的内存不断增加。 There's no different from StackPanel in term of memory 在内存方面与StackPanel没有什么不同

How UI virtualization work? UI虚拟化如何工作? How to keep memory low when adding new item to listStudent ? 将新项目添加到listStudent时如何保持低内存?

virtualization means list do not construct the list items which you have not scroll to yet. 虚拟化意味着list不会构建您尚未滚动到的列表项。

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 您可以将转换器绑定到学生的名字道具,然后将其记录下来。

确保您没有修改破坏用户界面虚拟化的ListBox ItemsPanel

Sheldon_Xiao指出了MSDN上的一些参考资料,这些参考资料有助于解释UI虚拟化

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM