Loading a datagrid with large amounts of data in silverlight?
I am breaking up my project in small sections and one of the sections involves loading a grid with possibily lots of records (could be up to 1000s of records in the database).
Ideally I would like some sort of mechanism where as the users scrolls the grid, more data is retrieved.
I have开发者_Go百科 read that certain controls (datapager with RIA) do this but I would like to know how I could implement this myself or do something similiar?
I was thinking about first loading 50 records at a time and when the user gets to scroll near the 50th record, then get another 50 as a start and so on. Not sure how I do this but this does not feel right or whether I should load ids of records in the grid and then get each row to load itself via an async thread but then I am hitting my database for each record?
Thanks
JD.
Sounds like you are describing data virtulization. Xceed seems to be working on a commercial control with this capability but to date have not realeased anything(see Xceed DataGrid for Silverlight Tech Preview! ). For some ideas from the WPF world on doing this you can check out:
- Data virtualization
- How can I improve on existing WPF data virtualization solutions?
I have just published a couple of articles with some sample code describing how to do stealth paging/data virtualization in silverlight without using any third-party components.
Read the introductory post to find out about the sample, and then follow up with Digging into VirtualCollection.
精彩评论