开发者

Observable Collections and Linq for Silverlight on Windows Phone

开发者 https://www.devze.com 2023-02-16 02:23 出处:网络
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 p开发者

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 p开发者_StackOverflow中文版opulate 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?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消