Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
IComparer - Comparing values from the DataRecord instead of the CellValue


We are using a XamDataGrid with a number of columns, but no grouping. One of the columns must be sorted, not by the values in the column, but by another value from the same DataRecord.
I've looked at the following posts:

The mentioned solution is interesting.
However, these only seem to work when grouping.
Is it possible do this without grouping, and to pass the DataRecord to the ICompare function instead of the cell values?


P.S. our current ICompare function is as follows. The objects are always strings, which means the cast never works.

// TODO: this only compares strings, not the totalStatusWeight
public int Compare(object o1, object o2)
 var item1 = o1 as ControlTowerOrderItem;
 var item2 = o2 as ControlTowerOrderItem;
 if (item1 == null || item2 == null)
  return 0;

 return item1.TotalStatusWeight.CompareTo(item2.TotalStatusWeight);

Parents Reply Children
No Data