private void uxListColumnHeader_Click(object sender, RoutedEventArgs e) { GridViewColumnHeader column = (sender as GridViewColumnHeader); string sortBy = column.Tag.ToString(); if (listViewSortCol != null) { AdornerLayer.GetAdornerLayer(listViewSortCol).Remove(listViewSortAdorner); uxList.Items.SortDescriptions.Clear(); } ListSortDirection newDir = ListSortDirection.Ascending; if (listViewSortCol == column && listViewSortAdorner.Direction == newDir) { newDir = ListSortDirection.Descending; } listViewSortCol = column; listViewSortAdorner = new SortAdorner(listViewSortCol, newDir); AdornerLayer.GetAdornerLayer(listViewSortCol).Add(listViewSortAdorner); uxList.Items.SortDescriptions.Add(new SortDescription(sortBy, newDir)); }