public void OnSort(object sender, RoutedEventArgs e) { GridViewColumnHeader column = sender as GridViewColumnHeader; String field = column.Tag as String; if (_CurSortCol != null) { AdornerLayer.GetAdornerLayer(_CurSortCol).Remove(_CurAdorner); ListView.Items.SortDescriptions.Clear(); } ListSortDirection newDir = ListSortDirection.Ascending; if (_CurSortCol == column && _CurAdorner.Direction == newDir) { newDir = ListSortDirection.Descending; } _CurSortCol = column; _CurAdorner = new SortAdorner(_CurSortCol, newDir); AdornerLayer.GetAdornerLayer(_CurSortCol).Add(_CurAdorner); ListView.Items.SortDescriptions.Add( new SortDescription(field, newDir)); }
public void OnSort(object sender, RoutedEventArgs e) { GridViewColumnHeader column = sender as GridViewColumnHeader; String field = column.Tag as String; if (_CurSortCol != null) { AdornerLayer.GetAdornerLayer(_CurSortCol).Remove(_CurAdorner); ListView.Items.SortDescriptions.Clear(); } ListSortDirection newDir = ListSortDirection.Ascending; if (_CurSortCol == column && _CurAdorner.Direction == newDir) newDir = ListSortDirection.Descending; _CurSortCol = column; _CurAdorner = new SortAdorner(_CurSortCol, newDir); AdornerLayer.GetAdornerLayer(_CurSortCol).Add(_CurAdorner); ListView.Items.SortDescriptions.Add( new SortDescription(field, newDir)); }