Reputation: 6543
Can any one please guide me which is best way to sort/filter observable collection and get back observable collection not IEnumerable ?
Upvotes: 1
Views: 1189
Reputation: 11868
You may have a look at my ObservableView
implementation which wraps an observable collection (or other list) and provides "live" ordering and filtering:
https://mytoolkit.codeplex.com/wikipage?title=ObservableView
Upvotes: 0
Reputation: 3478
If the result of sorting/filtering is IEnumerable<T>
then you can just create another ObservableCollection
and pass result as a parameter to constructor
Upvotes: 1
Reputation: 914
Probably for the sort you can convert it to a List and then call Sort(), providing a comparison delegate. Something like:-
my_collection.ToList().Sort((left, right) => left == right ? 0 : (left > right ? -1 : 1));
Upvotes: 1