private void GridViewColumnHeader_Click(object sender, RoutedEventArgs e) { GridViewColumnHeader column = (GridViewColumnHeader)sender; ListSortDirection direction; if (sortByColumn != null && sortByColumn.Content == column.Content) { direction = sortingDirection == ListSortDirection.Ascending ? ListSortDirection.Descending : ListSortDirection.Ascending; sortingDirection = direction; } else { sortByColumn = column; direction = ListSortDirection.Descending; sortingDirection = ListSortDirection.Descending; } Globals.sortBy(ContractsListView, column.Tag.ToString(), direction); }