示例#1
0
        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;
        }
示例#2
0
 public static void SetCustomSorter(DataGridColumn gridColumn, ICustomSorter value)
 {
     gridColumn.SetValue(CustomSorterProperty, value);
 }
 public static void SetCustomSorter(DataGridColumn gridColumn, ICustomSorter value)
 {
     gridColumn.SetValue(CustomSorterProperty, value);
 }
 public static void SetCustomSorter(DataGrid grid, ICustomSorter value)
 {
     grid.SetValue(CustomSorterProperty, value);
 }
示例#5
0
 public ColumnHolder(DataGridColumn column, int sortOrder, ICustomSorter customSorter = null)
 {
     this.column       = column;
     this.sortOrder    = sortOrder;
     this.customSorter = customSorter;
 }