Click here to Skip to main content
11,485,334 members (77,703 online)
Rate this: bad
good
Please Sign up or sign in to vote.
how to set wpf datagrid rendering fast for large data? help with me.

Search button click event
 
private void Search_Click(object sender, RoutedEventArgs e)
{
try
{
 
dgMMSize.ItemsSource = _mmsize.GetMMSize(txtId.Text);
}
catch (Exception ex)
{
if (stack.ToLower() == "true")
logService.Error(ex.ToString());
else
logService.Error(ex.Message.ToString());
 
MessageBox.Show(ex.Message);
}
}

Search click takes 16 sec before any data is showing.
Posted 13-Aug-14 21:44pm
Edited 14-Aug-14 3:40am
Kim Togo26.5K
v2
Comments
Kim Togo at 14-Aug-14 2:52am
   
How much data, 1000, 10.000, 1.000.000 items?
Are you doing any WPF styling or are you using Grouping for the DataGrid?
sureshsankar at 14-Aug-14 5:06am
   
any example code?
Kim Togo at 14-Aug-14 5:10am
   
Show the WPF XAML where you put in the ItemSource and the layout for your WPF DataGrid.
Kim Togo at 14-Aug-14 5:11am
   
Just hit "Improve question" and update with example code
sureshsankar at 14-Aug-14 8:28am
   
Search button click event

private void Search_Click(object sender, RoutedEventArgs e)
{
try
{

dgMMSize.ItemsSource = _mmsize.GetMMSize(txtId.Text);
}
catch (Exception ex)
{
if (stack.ToLower() == "true")
logService.Error(ex.ToString());
else
logService.Error(ex.Message.ToString());

MessageBox.Show(ex.Message);
}
}
sureshsankar at 14-Aug-14 8:31am
   
if click search button after 16 sec came for data
Kim Togo at 14-Aug-14 8:36am
   
Normal in WPF, you only set ItemsSource one time and uses Filter functions to tell what data DataGrid has to show.
My guess is that "_mmsize.GetMMSize" is doing a SQL search and returns an array or list of data ?
Sergey Alexandrovich Kryukov at 14-Aug-14 2:56am
   
This is not a good question. The problem is: WPF rendering per se is really fast. It means that you probably designed something in way which gives you a performance problem. But how can we know how did you run into this problem, how do you bind, populate data, etc?
—SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

How long time does it take to get data in "_mmsize.GetMMSize(txtId.Text)" ?

Change you code to:
System.Diagnostics.Stopwatch t1 = System.Diagnostics.Stopwatch.StartNew();
var data = _mmsize.GetMMSize(txtId.Text);
t1.Stop();
MessageBox.Show(t1.Elapsed);
 
t1.Restart();
dgMMSize.ItemsSource = data;
 
t1.Stop();
MessageBox.Show(t1.Elapsed);

Perhaps it is a search in SQL ?

Normal in WPF, you only set ItemsSource one time and uses Filter functions to tell what data DataGrid has to show.

My guess is that "_mmsize.GetMMSize" is doing a SQL search and returns an array or list of data ?
  Permalink  
v2
Comments
sureshsankar at 14-Aug-14 9:55am
   
list
sureshsankar at 14-Aug-14 10:01am
   
i am used list of data
sureshsankar at 14-Aug-14 10:21am
   
how set fast load in datagrid
Kim Togo at 15-Aug-14 3:02am
   
How long does it takes to get all the data in "_mmsize.GetMMSize(txtId.Text);" ?
sureshsankar at 16-Aug-14 1:44am
   
more then 15 sec
Kim Togo at 16-Aug-14 3:58am
   
Then the problem is not WPF DataGrid, but the problem is in GetMMSize that takes along time to get all the data.
sureshsankar at 16-Aug-14 5:46am
   
normal window datagrid rendering is fast, but am using MDI child window datagrid is very slow.How to fix.
Kim Togo at 16-Aug-14 6:32am
   
If getting data in "_mmsize.GetMMSize(txtId.Text);" takes 15 sec., then the problem is in "_mmsize.GetMMSize(txtId.Text);" not the DataGrid?
sureshsankar at 16-Aug-14 9:20am
   
i am using MVVM LIGHT 4.5
Kim Togo at 16-Aug-14 13:52pm
   
? Okay. If getting data in "_mmsize.GetMMSize(txtId.Text);" takes 15 sec., then the problem is in "_mmsize.GetMMSize(txtId.Text);" not the DataGrid?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 380
1 Maciej Los 365
2 Mehdi Gholam 210
3 Frankie-C 134
4 OriginalGriff 134
0 Sergey Alexandrovich Kryukov 8,819
1 OriginalGriff 7,982
2 Sascha Lefèvre 3,199
3 Maciej Los 2,841
4 Richard Deeming 2,370


Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 14 Aug 2014
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100