I have a WPF DataGrid bound to a CollectionViewSource that encapsulates an ObservableCollection. This CollectionViewSource has two main objectives:
1) To group each
The answer given by trilson86 is excellent. However, the third parameter in the two DependencyProperty declarations is incorrect. Instead of DataGrid and DataGridColumn, they should be CustomSortBehaviour, as such:
public static readonly DependencyProperty AllowCustomSortProperty =
DependencyProperty.RegisterAttached("AllowCustomSort",
typeof(bool),
typeof(CustomSortBehaviour), // <- Here
new UIPropertyMetadata(false, OnAllowCustomSortChanged));
public static readonly DependencyProperty CustomSorterProperty =
DependencyProperty.RegisterAttached("CustomSorter",
typeof(ICustomSorter),
typeof(CustomSortBehaviour)); // <- Here
I kept getting a warning that the AllowCustomSort property was already registered. A little research led me to the answer here.
At any rate, it's an excellent answer, so thank you.