Column Sort: put "Null" references to the end

Nov 19, 2008 at 4:37 PM
I am showing a custom class in the column. This class has ToString() & CompareTo().

However, automatic sorting always puts null references ahead of any other values while I need to put those values at the end of the column. How can I do it?
Coordinator
Nov 19, 2008 at 7:36 PM
If your implementation of  IComparable.CompareTo treats null references appropriately (unless your object is convertable to string by casting), DataGrid should sort them appropriately. DataGrid would just use your implementation of IComparable.CompareTo. If you want this behavior only within DataGrid and dont want to change the CompareTo method itself, then you can use the Custom sorting on DataGrid using DataGrid.Sorting event.

Here are the details of custom sorting http://www.codeplex.com/wpf/Wiki/View.aspx?title=Custom%20Sort&referringTitle=Tips%20%26%20Tricks
Coordinator
Nov 19, 2008 at 7:37 PM
I think you will probably have to implement a custom sorting algorithm to achieve this.  There links to instructions for implementing a custom sort here: http://www.codeplex.com/wpf/Wiki/View.aspx?title=Custom%20Sort&referringTitle=Tips%20%26%20Tricks.