I can't find how to add custom sorting to WPF ListView control? I don't need to sort by columns asc or desc, I need a custom one with some algorithm in it?
can you help me?
Thank you!
I can't find how to add custom sorting to WPF ListView control? I don't need to sort by columns asc or desc, I need a custom one with some algorithm in it?
can you help me?
Thank you!
You can use CustomSort property on ListCollectionView provided that you implement IComparer for your class:
//somewhere in code behind of your window:
var view = (ListCollectionView)CollectionViewSource.GetDefaultView(Items); //Items is an ObservableCollection<T>
view.CustomSort = new MyComparer(); //MyComparable implements IComparer
Any control bound to your Items such as ListBox will display elements in order.