开发者

using Icomparer to sort with special condition

开发者 https://www.devze.com 2023-02-13 02:46 出处:网络
In my project i have a need to sort the datagrid column but if a certain 开发者_如何学编程condition holds true for an item it should be at the top(first item) of the sorted list. otherwise if that con

In my project i have a need to sort the datagrid column but if a certain 开发者_如何学编程condition holds true for an item it should be at the top(first item) of the sorted list. otherwise if that condition does not hold for any item it should be simple sorted list.

I tries using sorting event and defining iComparer but i could not manage to get the desired behavior. What code will i put in Icomparer so that it can return the item with condition a true at the top and rest item in sorted fashion.

please can someone help


It sounds like you want to sort by the "certain condition" an then by the other sort critiria. This should just be a case of prepending condition to the list of sort descriptions in the CollectionView.

0

精彩评论

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