У меня есть привязка DataGrid WPF к CollectionViewSource, который инкапсулирует ObservableCollection. Этот CollectionViewSource имеет две основные цели:
1) Чтобы сгруппировать каждый элемент по определенному свойству T. Я использую ValueConverter в GroupDescription, чтобы получить поведение группировки, которое я хочу.
2) Сортировка сетки: a) в первую очередь имя группы (как определено выше) и b) отдельные элементы группы. Я достигаю этого, присоединяя пользовательский IComparer к свойству CustomSort CollectionViewSource.
Это работает отлично по большей части, однако, как только щелкнет заголовок столбца, логика сортировки переопределена. Я не хочу отключать сортировку, однако мне было интересно, можно ли назначить настраиваемый порядок сортировки для определенного столбца?
Чтобы сделать вещи более ясными, предположим, что пользователь нажимает "ColumnA" - на данный момент логика сортировки, инкапсулированная моим CustomSorter, переопределяется, и DataGrid теперь сортируется по этому свойству. Вместо сортировки по выбранному свойству я хотел бы вместо этого изменить логику CustomSorter.