What is a good way to get a ordered collection from a view model for bindings with MVVM Light?
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.
精彩评论