Anyone experienced with the WPF DataGrid?

Soldato
Joined
20 Oct 2008
Posts
12,082
I'm just getting started with WPF (C# .Net 4.5.1).

I'm using the standard WPF DataGrid control in a few places and setting the ItemsSource in the code behind to a Linq to SQL query.

It's all working as I want except that when I update the ItemsSource I loose any user applied column sorts.

Is there a simple way to persist the sort information when the ItemsSource is updated? At this point I don't really care how its implemented; it's something I can comeback to at a later date if I need to.

I thought It'd be an easy Google search but seems not.
 
Associate
Joined
7 Nov 2013
Posts
255
Location
Kent, England
Rather than setting the value for ItemsSource multiple times, set it once to an ObservableCollection, then Clear/AddRange your items to the backing collection.
 
Last edited:
Back
Top Bottom