views:

492

answers:

2

Hi all,

I am facing a scenario here.

I have a main class which initializes a DataGrid added in MainWindow of wpf application. There is a thread class in which DataTable object is passed by ref and that thread is responsible for updating the DataTable. As the thread runs the DataTable gets updated but but the view does not get updated.

But when i update/Add Row in the DataTable in the main class where the DataSet is initialized via TimeTicker not only the data add via later thread is updated in view but also the data added in timeticker method which is irrelevant.

Abdul Khaliq

+2  A: 

You mentioned you have another thread (I presume this is different than the UI thread) updating the DataTable. That doesn't sound right since the DataGrid should be updated on the UI thread. I'd try to ensure you are updating the grid on the UI thread via something like below. This is my best guess without seeing your code.

if (Dispatcher.CheckAccess())
{
    // already on UI thread
    UpdateDataGrid();
}
else
{
    // run UpdateDataGrid on UI thread
    Dispatcher.BeginInvoke(new YourDelegate(UpdateDataGrid), null);
}
Taylor Leese
+2  A: 

actuall the DG needs to be refreshed like gd.items.refresh() solved the problem.

Abdul Khaliq
Shimmy