private static void HandleCustomSorting(object sender, DataGridSortingEventArgs e) { DataGrid dataGrid = sender as DataGrid; if (dataGrid == null || !GetAllowCustomSort(dataGrid)) { return; } ListCollectionView listColView = dataGrid.ItemsSource as ListCollectionView; if (listColView == null) { throw new InvalidCastException("ItemsSource property must be type of ListCollectionView."); } ICustomSorter sorter = GetCustomSorter(e.Column); if (sorter == null) { return; } e.Handled = true; ListSortDirection direction = (e.Column.SortDirection != ListSortDirection.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending; e.Column.SortDirection = direction; sorter.SortDirection = direction; listColView.CustomSort = sorter; }
public static void SetCustomSorter(DataGridColumn gridColumn, ICustomSorter value) { gridColumn.SetValue(CustomSorterProperty, value); }
public static void SetCustomSorter(DataGrid grid, ICustomSorter value) { grid.SetValue(CustomSorterProperty, value); }
public ColumnHolder(DataGridColumn column, int sortOrder, ICustomSorter customSorter = null) { this.column = column; this.sortOrder = sortOrder; this.customSorter = customSorter; }