如何在 Windows Phone 中对在线内容进行数据虚拟化? [英] How to do Data Virtualization for online content in windows phone?
问题描述
我有一个从互联网获取内容的应用.那些信息太大了,内存都放不下.
I have an app which gets content from internet. those pieces of information are so large and can't fit in memory.
LongListSelector
UI Virtualization
做得很好.仍然是数据虚拟化
.我认为解决方案是先将数据保存在数据库中然后显示它.
LongListSelector
does UI Virtualization
well. remains Data Virtualization
. I thought the solution is to save data in database first then show it.
我不知道该怎么做,这些是我脑海中的问题:
I have no idea how to do it and these are questions in my head:
- 这是我应该做的
数据虚拟化
吗? - 如果没有足够的空间会发生什么.
- 感谢任何来源或提示.
谢谢.
推荐答案
数据虚拟化的基本思想是创建可以加载 & 的自定义集合.按需退货(无需事先在内存中加载完整集).以下是从根本上简化的实现(改编自 这篇博文) :
Basic idea of data virtualization is creating custom collection that can load & return item(s) on-demand (without prior loading complete set in memory). Following is radically simplified implementation (adapted from this blog post) :
namespace VirtualizingDataTest
{
public class VirtualizedDataSource : IList
{
public object this[int index]
{
get
{
string text = "Requesting " + index;
Debug.WriteLine(text);
return "Item " + index;
}
set
{
throw new NotImplementedException();
}
}
}
在上面的示例中,根据请求创建了新项目.在您的情况下,如果在线资源提供了一种在特定索引中请求项目的方法,则您不需要数据库.您可以在 this[]
getter 中放置下载特定项目的逻辑.可以在此处找到更多参考(各种更好/更完整的实现):https://stackoverflow.com/a/6712373/2998271一个>
In the sample above, new item created upon requested. In your case, if the online source provide a way to request item in specific index, you don't need database. You can put logic to download specific item in this[]
getter. Further references (various better/more complete implementation) can be found here : https://stackoverflow.com/a/6712373/2998271
给定 UI 虚拟化工作,LLS 将只请求显示项目的子集(换句话说,this[]
不会为所有可用索引调用 getter,只会显示那些).
Given UI virtualization working, LLS will request only sub set of items to be displayed (in other words, this[]
getter won't get invoked for all index available, only those to be displayed).
这篇关于如何在 Windows Phone 中对在线内容进行数据虚拟化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!