How to refresh DataGrid on a separate thread

Oct 16, 2009 at 7:22 PM
I have a DataGrid whose underlying data comes from a LinqToSql
EntitySet. The backend data may change outside the application so it's
necessary to refresh the data and refresh the DataGrid. The application
becomes completely unresponsive when I try to call Refresh on the
DataContext:

AppData.Db.Refresh(RefreshMode.KeepChanges, AppData.Db.JobOrdTables);

And there are only 4 records in JobOrdTables.

Is this a DataGrid issue or a LinqToSql issue?


Thanks,


Bill
Coordinator
Oct 16, 2009 at 9:57 PM

Hey Bill, To get the updates you actually need to set the ItemsSource to null and then back to your backend; just calling refresh won't be sufficient.  I know that is not a totally satisfying answer but hope it helps!

Oct 19, 2009 at 2:59 PM
I've tried that it it seems no different to just reseting the ItemsSource.

What I ended up doing was calling dispose on the DataContext and then
rebuilding it. That appears to be the fastest refresh.

Bill

On 10/16/2009 3:57 PM, alexisr wrote:
>
>
> From: alexisr
>
> Hey Bill, To get the updates you actually need to set the ItemsSource to
> null and then back to your backend; just calling refresh won't be
> sufficient. I know that is not a totally satisfying answer but hope it
> helps!
>
> Read the full discussion online
> <http://wpf.codeplex.com/Thread/View.aspx?ThreadId=72250&ANCHOR#Post246702>.
>
> To add a post to this discussion, reply to this email
> ([email removed]
> <mailto:[email removed]?subject=[wpf:72250]>)
>
> To start a new discussion for this project, email
> [email removed] <mailto:[email removed]>
>
> You are receiving this email because you subscribed to this discussion
> on CodePlex. You can unsubscribe or change your settings
> <https://wpf.codeplex.com/subscriptions/thread/project/edit> on
> codePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any
> posts to this discussion will also be available online at codeplex.com
>