DataGrid: Sort does not update when data item changes

Jun 23, 2009 at 11:20 AM


 I am evaluating the WPFTools HaloGrid for potential use in a large project and found an issue or lack of feature.

I Have a DataGrid bound to an ObservableCollection of custom objects. The objects do implement the INotifyPropertyChanged interface. I have noticed that if I have the grid sorted, and if I update the value of a field , which happens to be sorted on, the value is updated correctly on the grid, but the sorting does not update based on the new value.

I believe this is because the grid does not update the sort on PropertyChanged event of its items? I can make it update the sort by firing a CollectionChanged event or Doing a refresh on the view from the collection. But these don't seem to be very efficient. Shouldn't the grid, on propertychanged, check if the change is on a sorted column and if so update the sorting automatically? Am I doing something wrong, or should I request this as feature?

thanks and regards


Jun 23, 2009 at 9:18 PM

Hi Bijesh,

We aren't able to reproduce this problem; if you attach a small application that shows this we will investigate.



Jun 24, 2009 at 5:31 AM

Hi Alexis,

 As you may know this forum is not allowing attachments, and the notification mail also says clearly that attachments will be deleted. Can you tell me how to send the sample. Am surprised that you are unable to recreate this as I am easily able to do it even on the sample that is available here

I can demonstrate the issue on that sample by having an update button which will chnage the value of one of the data columns. Then if I sort the gird by that column, and then click update, the grid value changes but the sort order does not.


Jun 24, 2009 at 5:49 AM

Hi Alexis

I have created this as an issue and attached the sample project and screenshot with it. The issue number is 10183. Please let me know if you have any update?

thanks and regards,


Sep 3, 2009 at 8:21 AM
Edited Sep 3, 2009 at 8:27 AM


Is there any update on this issue? I can't find it in the issue tracker and I have this problem too. 

EDIT: I found it..

Sep 3, 2009 at 3:46 PM

Have you tried calling a Refresh in the CollectionView after you update the data?

Sep 4, 2009 at 8:35 AM

HI Myzli, Is it issue number 10183 you are referring to? Or was there any other?

Yes doing a refresh on the collection view would work, But the problem is it is not very efficient. And anyway the grid should do this automatically (or atleast have an option to have it done automatically) rather than having to do an extra refresh...



Sep 4, 2009 at 8:55 AM

Hi! Yes, it is 10183 I'm referring to.

Cells in my grid will be updated very frequently and I'm afraid refreshing will be to inefficient but I'll try it out... 

Sep 4, 2009 at 2:33 PM

I tried to do a refresh on the CollectionView but I'm not sure I do it right (probably not since not much happens ;)) I do like this: 



        void RefreshDataGridItems()
            var view = CollectionViewSource.GetDefaultView(dataGrid.ItemsSource);

            if (view == null)


I'm new to WPF and maybe I've misunderstood how to get the current CollectionView for the DataGrid, do you have an example? 




Sep 4, 2009 at 9:24 PM

Hi myzli,

Please try the following:



Hope that helps,

Saied K.

Sep 7, 2009 at 9:58 AM

Hi Saied! 

I tried your code and it gave no result. I can see that it has some effect since I have some background colors that disappears when the items are refreshed but i doesn't effect the sorting. If I clear the SortDescriptions and then add the SortDescription again and refresh the grid is sorted (like this:)



            var view = CollectionViewSource.GetDefaultView(dataGrid.Items);

            if (view == null)

            if (view.SortDescriptions.Count == 0)

            var description = view.SortDescriptions[0];

            using (view.DeferRefresh())


Jan 15, 2010 at 12:02 PM

Has something been done about this? I'm on a similar situation with the aggravation that my DataGrid is inside a DataTemplate for a ContentControl, on a ResourceDictionary, so I don't have code-behind where I can easily access it and it isn't always there anyway. I'm amazed that there isn't an option to autorefresh the order when the data objects' properties change.


-Sergi Díaz