Project Description
Use SortingObservableCollection and stop worrying about ever having to keep your items in order!


Right now, this only contains SortingObservableCollection, which derives from ObservableCollection. This is different from other implementations that I've seen because XAML controls like GridView don't work with you unless you inherit from ObservableCollection (see http://stackoverflow.com/questions/1945461/how-do-i-sort-an-observable-collection/5401474?noredirect=1#comment28453374_5401474).

Currently, it's unit tested to 98% code coverage. I've used it in several projects with success. Available on NuGet: https://www.nuget.org/packages/sortingobservablecollection/

Sample usage:

var collection = new SortingObservableCollection<MyViewModel, int>(Comparer<int>.Default, model => model.IntPropertyToSortOn);

collection.Add(new MyViewModel(3));
collection.Add(new MyViewModel(1));
collection.Add(new MyViewModel(2));
// At this point, the order is 1, 2, 3
collection0.IntPropertyToSortOn = 4; // As long as IntPropertyToSortOn uses INotifyPropertyChanged, this will cause the collection to resort correctly

Last edited Jan 30, 2014 at 5:02 PM by westont, version 3