SoggyB
SoggyB

Reputation: 23

Observable Collections and Linq for Silverlight on Windows Phone

I am binding to observable collections, but not sure how to filter and order them with linq. I need them to be observable, otherwise my bindings won't be notified of changes (right?). When you populate an observable collection, will it retain the order items were added to it?

I am not sure where to go from here.

For databinding, is there another type of collection that is observable, but that you can use linq on?

Upvotes: 2

Views: 325

Answers (2)

Derek Lakin
Derek Lakin

Reputation: 16319

If you need to provide filtering and sorting on top of your list data, then you should probably use CollectionViewSource for binding rather than ObservableCollection. Geoff Hudik's post: WP7 In-App Searching, Filtering covers this.

Upvotes: 1

Maciek
Maciek

Reputation: 19893

ObservableCollection is the recommended collection to use when you know that the underlying data will change.

It will retain the order of items in which they were added

You can use other collections for databinding as well, Linq can be used on pretty much anything that implements IEnumerable.

Upvotes: 0

Related Questions