I’ve encountered an issue with XamDataGrid when attempting to filter a template field using alternate Binding.

I am trying to Filter a field using another field(which has the real data on which the user will filter on)

In the attached solution, sorting works – however on filtering – the search text keeps disappearing (I think this is due to us changing the recordfilter field to another field at the point before which we apply the pending filter).

I have tried using a converter but that seems to break the sortcomparers as we get the converted value instead of the object.

I have been looking into the sample application you have provided and the functionality you are looking for.

I believe in your scenario you can create a new RecordFilter for your Salary field. You can set its Operator and Value properties based on the current RecordFilter in RecordFilterChanged event handler, then you can add this filter to the RecordFilters collection of XamDataGrid.

I've just ran your updated solution and whilst the filter works , the sort comparer is now broken as it receives string value rather than the object with which we can perform our sort. Isn't it possible to have both filter and sort comparer work in tandem?

I have been looking further in your scenario and modified your sample application in order to show you how you can achieve your goal.

It seems that in order to filter on Field that is bound to complex types data(in your case PersonViewModel), you should implement IComparable interface in this class for your object. This way the XamDataGrid will be able to know how to filter your complex type data.

You can take a look at the following forum thread where similar approach has posted form Stefan Stoyanov:

Your solution still relies on trimming the alphabets. We've got different conventions for how numbers are formatted and as such can't rely on trimming strings as they do not represent the actual underlying value.

Is there a workaround with the comparer that gives the actual objects for comparison?

I have been looking into it and it seems I am not sure that I understand correctly what you have in mind with ‘Your solution still relies on trimming the alphabets’, would you please provide me with example of this issue(scenario where this solution breaks the logic ), this way I would be able to further investigate this issue for you?

As I mentioned before in your case you are working with custom type data(PersonViewModel), because you have bound the Field to whole DataItem. When you filter in the custom Comparer of this field you receive the value of the cell as string, because the XamDataGrid does not know how to filter the data from custom type.