0
Answer

Visual Studio 2012, WPF DataGrid slow in refresh

TAN WhoAMI

TAN WhoAMI

11y
1.8k
1
Hi,

I am using Visual Studio 2012 Ultimate, create a WPF application which loads in Customer data of 91 rows from Northwind database, using ADO.NET Entity Data Model.


The horizontal scrollbar is ok to refresh the data, I am able to drag it and the DataGrid is able to scroll to the left and right smoothly.


But for the vertical scrollbar, I am not able to drag it up or down easily. I can only click it at the top or bottom of the vertical scrollbar, and the DataGrid needs 5 seconds to be able to scroll up or down, which is not acceptable.


Has anyone encounter anything like this before?


I am using Windows 7 SP1, with 2GB RAM.
I will try to verify whether I have the same problem when using Visual Studio 2010.


thanks.
================
I realise the culprit has to do with this line of code:

dataGrid1.ItemsSource = context.Customers.ToList();

but if I do not have the above line code, and with only below code, DataGrid does not get updated.

dataGrid1.Items.Refresh(); 

the full code is as attached.


Attachment: code.zip