开发者

What is a good way to get a ordered collection from a view model for bindings with MVVM Light?

开发者 https://www.devze.com 2023-03-08 15:06 出处:网络
I have a view model that currently exposes an ObservableCollection. With my WP7 app, I need to show a secondary screen that basically lets you sort what comes out of the collection, and youto the resu

I have a view model that currently exposes an ObservableCollection. With my WP7 app, I need to show a secondary screen that basically lets you sort what comes out of the collection, and you to the results again.

I started adding a ApplyOrder method on the view model to address this, but quickly realized I was not sure what direction to take, as when you add the orderby, you wind up with an IOrderedEnumerable.

What is the best way to get those results ordered?

开发者_开发百科

Thanks, Roger


CollectionViewSource is your friend.

Assign its Source property to your ObservableCollection and Add one or more SortDescriptions.

0

精彩评论

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