[WPF] Updating sorting in DataGrid when OnPropertyChanged?

So I'm sorting a list by a bool value, so that the online items are always at the top:

 public bool Online { get { return _online; } set { _online = value; OnPropertyChanged("Online"); } } 

Updating the ObservableCollection items via dispatcher works great, no problems at all with that.

Problem is that it doesn't automatically resort. I'd rather not re-list it every time, since I don't want it to clear the user's selection in the datagrid.

Is there any way to force a re-sort when the "set" is triggered for a value, that doesn't force the user to lose their selection?


by TripW via /r/csharp

Leave a Reply