private void RealtorsGrid_Sorting(object sender, DataGridSortingEventArgs e) { e.Handled = true; ListSortDirection direction = (e.Column.SortDirection != ListSortDirection.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending; e.Column.SortDirection = direction; ListCollectionView lcv = (ListCollectionView) CollectionViewSource.GetDefaultView(dataGrid.ItemsSource); SortLogic sortLogic = new SortLogic(direction, e.Column); lcv.CustomSort = sortLogic; }