开发者

SortDescriptions

开发者 https://www.devze.com 2022-12-13 12:47 出处:网络
I\'m using c# in combination of WPF. I\'ve used a CollectionView with a single SortDescription. But in certain cases the SortDescription is not used. Yet I couldn\'开发者_如何学Got find out why this

I'm using c# in combination of WPF.

I've used a CollectionView with a single SortDescription. But in certain cases the SortDescription is not used. Yet I couldn'开发者_如何学Got find out why this is happening.

The ComboBox isn't sorted for some reason. When I add a second SortDescription with the same sorting option it also happens.

No cv.sortdescriptions.clear(); is used for this particular SortDescription. In 99% of the cases it works perfect, but somehow for one reason yet this happening.

Anyone have a clue?


as a side note, it would be more performant to use the CustomSort property. Apparently the SortDescriptions uses reflection, so for large sets of data, it is unacceptably slow.

check this blog for more information


What is the type of the property you're sorting on?

WPF's SortDescription only sorts on properties that implement IComparable. Note that implementing IComparable<T> isn't enough - you need to explicitly implement the non-generic interface.


Depending on the type of collection, it's possible that your CollectionView.CanSort is false. In this case, sorting will not work, and the SortDescription will be ignored.

0

精彩评论

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