开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜