简体   繁体   English

从独立存储向WP7列表框中添加数百个图像,如何利用数据虚拟化?

[英]Adding hundreds of images to a WP7 listbox from Isolated Storage, how can I utilize Data Virtualization?

I am trying to add images to a listbox with a "continuous scroll" so the user does not have to press any buttons etc to load the next set of images. 我正在尝试使用“连续滚动”将图像添加到列表框中,以便用户不必按下任何按钮等即可加载下一组图像。 The images are stored in Isolated Storage. 图像存储在隔离存储中。 I will be starting with 500 images. 我将从500张图片开始。 Loading 500 images to a listbox obviously does not work and just eats up all resources in a few seconds. 将500张图像加载到列表框显然不起作用,并且仅在几秒钟内就耗尽了所有资源。 Based on my research I need to use data virtualization so the images are retreived when they are required (on-screen) and disposed of when not-required (of-screen), as opposed to loading them all at once. 根据我的研究,我需要使用数据虚拟化,以便在需要时(在屏幕上)检索图像,并在不需要时(在屏幕上)处理图像,而不是一次加载所有图像。 I have searched the web for examples but have only been able to find code which retreives and displays text etc to populate the listbox as oposed to images stored in IS. 我在网上搜索了示例,但只能找到检索和显示文本等代码以填充列表框(与存储在IS中的图像相对)的代码。 I "belive" I need to use an Image within a Data Template, within a listbox and then bind to an IList using a custom class. 我“相信”我需要在列表框中的数据模板中使用图像,然后使用自定义类绑定到IList。 I can bind the list box to a basic IList and that works ok (only 50 images) but when it comes to creating a custom class etc its over my head. 我可以将列表框绑定到基本的IList,并且可以正常工作(仅50张图像),但是当涉及到创建自定义类等时,它就超出了我的头。 Does anyone have an example of what I need that they would be happy to share? 有没有人愿意分享我所需要的例子? I havent been programming a year yet and have found most of my App requirements to be achievable with a litte research but I cant find any good pages or video that explains this exact requirement and its driving me crazy as I have spent days on it. 我还没有编程一年,但发现我的大多数App需求都可以通过少量研究实现,但是我找不到任何能解释这一确切需求的好页面或视频,因为我花了很多天才使我发疯。

Failing that I will have to pay Telerik for their support and use their DataBoundListBox or pay a third party to write it for me, but I thought I would try here before parting with hundreds of dollars! 否则我将不得不向Telerik支付他们的支持并使用他们的DataBoundListBox或支付第三方为我编写它的费用,但是我想我会在这里尝试几百美元!

Thanks for your time(s) in advance! 感谢您的宝贵时间!

Here is a proper implementation of data virtualization: http://blogs.msdn.com/b/ptorr/archive/2010/08/16/virtualizing-data-in-windows-phone-7-silverlight-applications.aspx 这是数据虚拟化的正确实现: http : //blogs.msdn.com/b/ptorr/archive/2010/08/16/virtualizing-data-in-windows-phone-7-silverlight-applications.aspx

This is how you bind images to the image control: Image UriSource and Data Binding 这是将图像绑定到图像控件的方式: 图像UriSource和数据绑定

To get data Data Virtualization on the Windows Phone 7 you can use the VirtualizingStackPanel class. 要在Windows Phone 7上获取数据“数据虚拟化”,可以使用VirtualizingStackPanel类。 In the MSDN you can find all the properties you may want to set. 在MSDN中,您可以找到可能要设置的所有属性。 To use the control you put your list inside this control: 要使用该控件,请将列表放入此控件中:

<VirtualizingStackPanel>
  <YOUR LIST>
</VirtualizingStackPanel>

Since you would like to have a tutorial I can point you to Jevgeni Tšaikin blog post on ItemsControl virtualization . 既然您想学习一个教程,我可以将您引到JevgeniTšaikin上有关ItemsControl虚拟化的博客文章。 If you want more check out the post from Shawn Oster on Improving ListBox Performance . 如果您需要更多信息,请查看Shawn Oster的有关“ 改进ListBox性能”的文章

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

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