locked
ListView with custom ListDataAdapter requests items twice

    Question

  • I've implemented IListDataAdapter by creating a class derived from VirtualizedDataSource, but I'm seeing some odd behaviour when it's used by the ListView.

    When swiping right, itemsFromIndex is called repeatedly as expected to page in the data. When I swipe all the way to the right, it then requests all the items again from the start! I could cache the items to save fetching them again, but is there some way to change the behaviour of the ListView so it doesn't request the items twice? I would understand if it requested the items if I started scrolling left again, but I don't understand the current behaviour.

    Monday, September 03, 2012 9:24 AM

All replies

  • Of course this would only really matter if you had a lot of data correct?  For small amounts of data this is trivial.  By default once Listview hits a threshold of items it would start fetching data in a pre-defined data page size.  You can have a finer control of what gets fetched and when if you would like.  I actually just answered a question related to how listview fetches data incrementally here:

    http://social.msdn.microsoft.com/Forums/en-US/winappswithhtml5/thread/a82b6d34-e1d6-4d7d-a7cd-da69e6fbc3f2


    Jeff Sanders (MSFT)

    Wednesday, September 05, 2012 12:46 PM
    Moderator
  • Thanks Jeff, I'll have a play with the properties you link to in that answer.

    In this case, I'm not too worried about the unnecessary  web calls to fetch the data from the app's point of view, but my app is going to run in  an environment where bandwidth is scarce and shared with more critical infrastructure. 

    Wednesday, September 05, 2012 1:42 PM
  • I am very impressed that you are taking bandwidth into account!  Great job!  One thing you may consider is using an indexeddb or SQLLite to cache data locally and only go after data that has changed since your last data refresh.

    If you run into any problems let me know.

    -Jeff


    Jeff Sanders (MSFT)

    Wednesday, September 05, 2012 2:28 PM
    Moderator