WPF Datagrid Lazy load

11,682

Solution 1

Loading data: 200k rows is a lot of data that no one (user) wants to see in one place. It will definitely reduce your UI user experience. So your best bet is to filter your data just to reduce the amount of it (for example do not show closed orders, just show the open ones). If you can't do so, you should use Virtualization. I didn't see any applications that use pagination in order to show data (Of course except in web). Most of the time it isn't such a good approach. But if you are talking about a type of data that is like search engines results you must use it. But keep in mind that most users won't exceed page 10 in search engines results.

Filtering: I would suggest doing it on your server side for such a huge amount of data (SQL Server here), or as I said first filter the whole 200k to reduce the amount on server side and then filter it (for user) in order to find something, on the client side. You might also find the following link helpful:

  1. http://www.codeproject.com/KB/WPF/DataGridFilterLibrary.aspx

Sorting: Again I would suggest server-client solution but you might also find following links helpful:

  1. http://blogs.msdn.com/b/jgoldb/archive/2008/08/26/improving-microsoft-datagrid-ctp-sorting-performance.aspx
  2. http://blogs.msdn.com/b/jgoldb/archive/2008/08/28/improving-microsoft-datagrid-ctp-sorting-performance-part-2.aspx
  3. http://blogs.msdn.com/b/jgoldb/archive/2008/10/30/improving-microsoft-datagrid-sorting-performance-part-3.aspx

Many people don't use default SortMemberPath of WPF datagrid just because it uses reflection on every single record and this will highly reduce the performance of the sorting process.

Hosein

Solution 2

Here is a very good sample of Data Virtualization (Not UI Virtualization):

http://www.codeproject.com/KB/WPF/WpfDataVirtualization.aspx

Althogh it doesn't support the LINQ IQueryable objects directly but you can use this sample as it is. Of course I'm now wokring to improve it to work with IQueryable objects directly. I think it's not so hard.

Share:
11,682

Related videos on Youtube

Ravi Yenugu
Author by

Ravi Yenugu

Founder of Dollar($) Bill in my Jeans !

Updated on June 04, 2022

Comments

  • Ravi Yenugu
    Ravi Yenugu almost 2 years

    Details

    1. VS-2008 Professional SP1
    2. Version .net 3.5
    3. Language:C#

    I have a WPF Datagrid which loads from Linq-sql query Datacontext data item.The result set contains around 200k rows and its it very slow loading them,sorting,filtering etc. What is the simple and easy way to improve the speed?

    Couple of things I saw searching are Scrollview,Data virtualization etc people also talk about Paging,Profiling etc

  • Ravi Yenugu
    Ravi Yenugu about 13 years
    Can you provide some good reading material links to the paging idea?
  • Efren
    Efren about 13 years
    Sorry, I don't have a good reading materials for the paging code. You already have a full list with all the items. You can have second list which will hold, let's say, 10 items at most. What you do is show the user the second list, never the full list. Give the user a previous and next button, have an index pointing to the first item being shown. Next will add 10 to the index, recreate the second list, and refresh the display.
  • dansan
    dansan over 10 years
    Another option is to add a simple fade-in: you set the opacity to 0.0 and then add an event trigger for the OnLoad event to the style for the data grid row that includes a simple DoubleAnimation for the opacity.
  • Josh Noe
    Josh Noe about 7 years
    This should probably be a comment?
  • NoWar
    NoWar over 6 years
    It is a good example of derived VirtualizatingCollection, performing loading asychronously. Thank you!

Related