tags:

views:

550

answers:

3

Hi all,

I'm using c# in combination of WPF.

I've used an CollectionView with a single SortDescription. But in certain cases the SortDescription is not used. Yet I couldn't 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?

A: 

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.

Reed Copsey
Yet I had checked that, and that isn't changed in code or automatically.
pipelinecache
A: 

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.

Matt Hamilton
That's for sure, but the sortdescription does work in 99% of the cases. And isn't changed by code. I can't this issue in the programming environment or in the test environment. but the customer has this issue. And even the customer can't find this issue. It happens at strange moments, and the variables are always the same.
pipelinecache
+1  A: 

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

Muad'Dib