How to sort items in ListView by column bound to an Observable Collection ?
I've looked all over the place and 开发者_如何学CI can't find anything easy enough or simple on this.
Is the example here too complicated? It just shows how to use a ListCollectionView to provide the data in the correct order, and to perform the sorting.
You can use SortDescriptions in CollectionViewSource. Here is an example. If you want it dynamically, you need to code around this. but this should give you an idea.
List<Product> products = Client.GetProductList();
public ICollectionView ProductView = CollectionViewSource.GetDefaultView(products);
ProductView.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
精彩评论