How to do Data Virtualization for online content in windows phone?

前端 未结 1 1674
渐次进展
渐次进展 2021-01-16 09:22

I have an app which gets content from internet. those pieces of information are so large and can\'t fit in memory.

LongListSelector does UI Virtua

相关标签:
1条回答
  • 2021-01-16 09:35

    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\t" + index;
    
            Debug.WriteLine(text);
            return "Item " + index;
          }
          set
          {
            throw new NotImplementedException();
          }
        }
    }
    

    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

    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).

    0 讨论(0)
提交回复
热议问题