WP7 Listbox UI虚拟化如何工作 [英] WP7 Listbox how UI virtualization work

查看:72
本文介绍了WP7 Listbox UI虚拟化如何工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用具有VirtualizingStackPanel的ListBox,据说该列表默认支持UI虚拟化.

I'm using ListBox which has VirtualizingStackPanel, which is said to support UI virtualizing by default.

但是,当我将我的 listStudent (类型为ObservableCollection,并且有5个学生)设置为我的ListboxItemsSource时.然后,每当用户滚动到末尾时,我都会在我的 listStudent 中再添加5个学生(当然会通知用户界面).但是我看到消耗的内存不断增加.内存方面与StackPanel没有什么不同

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

UI虚拟化如何工作?将新项目添加到 listStudent 时如何保持低内存?

How UI virtualization work? How to keep memory low when adding new item to listStudent?

推荐答案

虚拟化意味着list不会构建您尚未滚动到的列表项.

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

例如

您可以将转换器绑定到学生的名字道具,然后将其记录下来.然后,您便知道该商品何时真正创建

you can bind a converter to student's name prop and you can log it .then you know when the item create indeed

这篇关于WP7 Listbox UI虚拟化如何工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆