Loading only data that comes into view

Nov 22, 2008 at 3:30 PM
How can I accomplish loading data on demand with wpf datagrid?
I have to display a lot of items in a datagrid. Because of performance reasons, it is not possible to fetch all data from the database.
I think of something like at first only to get a total items count (to scale the scrollbar) and then to get only that data from the database that comes into view.
Datagrid has UI virtualization as far as I know, but I'd rather need a feature like data virtualization. Is there a way to get this done?

Thanks in advance for any help.
Nov 25, 2008 at 3:49 PM
Hi heroicinventor,

Unfortunately the DataGrid (and none of the other WPF controls) support data virtualization out-of-the-box at the moment.  However, it is possible to roll your own using a strategy like you suggested if you're willing to write some code.  Some third-party providers also have data virtualization solutions.  I would recommend that you search online to find a solution which works for you, whether it be a guide to writing your own data virtualization (there are lots of blog posts about this) or a pre-built solution which you can purchase.  The WPF team does have data virtualization on our roadmap for a future release, but unfortunately it will not be available in our next release (.NET 4.0).

Jan 27, 2009 at 12:55 PM
Edited Jan 27, 2009 at 1:45 PM
Hi Samantha,

Concerning data virtualization, you write 
... search online to find a solution which works for you, .... (there are lots of blog posts about this)

I tried googling ... 

But no hits on experiences with doing data virtualisation with wpf.

Would you update this thread with a few links on this?

Jan 29, 2009 at 6:31 PM
Hi Paul,

I don't know of any non-third party (or open source) data virtualization solutions, and was not able to find any good instructions for implementing this yourself in a search either.  You might want to try posting a question to the MSDN forums: http://forums.microsoft.com/MSDN/default.aspx?siteid=1.  The experts in the forums on this site are specialized in WPF controls, particularly DataGrid and Ribbon, and the MSDN forums are visited by a variety of people with a greater breadth of knowledge, so someone there may be able to help you more than we can.

Mar 24, 2009 at 1:12 PM
Edited Mar 24, 2009 at 1:14 PM
I have just posted an article on CodeProject (http://www.codeproject.com/KB/WPF/WpfDataVirtualization.aspx), which may provide a solution.
Mar 31, 2009 at 9:08 AM
Apr 12, 2010 at 3:58 PM

Take a look at my blog post: