Make Sortdescription also sort databound collection that is bound to listview wpf c#

268 views Asked by At

I have a Listview that is Databound to an Observable Collection.

I have sorting implemented using SortingDirection ( applied it to The ListView and also tried applying it to a CollectionViewsource, after binding the CollectionViewSource also properly to the ListView ) The sorting of each column works without problems.

In my MainWindow.xaml.cs I change the positions of The Items in the Observable collection. To do this I have to clear the Sortingdirection applied to the ListViewSource, or it will resort the moving of files and The manuall up and down Movements will be overwritten by the sorting.

For this problem I need The sortdescription to Apply itself on the Bound Data, so I can remove it afterwards and still keep the sorted order.

Many people asked similar questions here, but answers always where "is it really important that the collection is sorted? DonĀ“t you just want to apply it on the view?" My answer to this is yes, it is really important. I would go with manually writing a sort for my collection, but it is databound and would fire events each time an object is changed during the Bubble Sort.

If anyone has a fix for this, please let me know.

Best regards.

1

There are 1 answers