I have a WPF DataGrid that in its first column holds a number that is the “ranking” or “position”. What I want is that when I click on a column to sort the table based on that column, for the first column to stay as-is.
For example:
Position Name Games Points PPG 1 John 2 10 5 2 Mary 3 12 4
when sorted by Games in descending order should become
Position Name Games Points PPG 1 Mary 3 12 4 2 John 2 10 5
Is there a way to do this? DataColumn doesn’t seem to have any such property, and FreezeColumnsCount only retains them in view at all times, but doesn’t stop them from being sorted along with the rest of the data.
In http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/ffd7037d-dd77-44ec-9011-d0d43d5706aa/ I just found an example (answer from Adbie) for what I suggested in my comment:
EDIT by OP:
I’ve just verified it works even without the binding. The cs code is fine, but in XAML you only need to do