Upendra Chaudhari
Upendra Chaudhari

Reputation: 6543

How to sort/filter observable collection and get back observable collection not IEnumerable

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

Answers (3)

Rico Suter
Rico Suter

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

psurikov
psurikov

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

See this question

Upvotes: 1

Chief
Chief

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

Related Questions