开发者

How to sort items in ListView by column bound to an Observable Collection?

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

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));
0

精彩评论

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

关注公众号