Hi,
I'm using a XamDataGrid. One of its columns is a bound integer field. Whenever I edit the value and type a non-integer value (e.g. 'test') there would be a validation error stating that "Value 'test' could not be converted." I would like to translate this message into a different language when the user changes culture. I believe I have to use an Infragistics resource customizer to accomplish this, but I cannot find this specific resource. I have been trying to find it via the following link:
http://help.infragistics.com/Help/NetAdvantage/WPF/2011.2/CLR4.0/html/WPF_Customize_Assembly_Resource_Strings.html
I have been searching for "Value '{0}' could not be converted." but cannot seem to find it in any of the links on that page. Where is it located?
I'm using netAdvantage v11.2
Regards, Stefan
Hello Stefan,
I have modified the sample further, so now I used a Converter in order to be able to set different text only if the error is for converting the value. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
Your solution is one step closer, but we're not there yet. The problem is now that the tooltip always contains the given text, regardless of what error occurred. However, as I mentioned before, the data objects from my actual project also implement IDataErrorInfo, and if the value conversion is successful, the new value will be evaluated by the interface.
I have modified the sample so that the data object has a very simple IDataErrorInfo implementation. Whenever the user enters text characters (e.g. 'blabla') the error tooltip should be the custom text which we discussed before, but if the user enters -150, the error message should be the IDataErrorInfo message ('cannot be negative', in this demo case).
I do appreciate your assistance!
I have modified the sample you have sent, so now the Tooltip is changed. Basically I copied the DataTemplate that is used when an error occurs and changed the Tooltip there. Please let me know if this helps you or you need further assistance on this matter.
Hi Stefan,
My sample did not show this, but in my real application the databound object already implements the IDataErrorInfo interface. The problem is that this interface cannot help me in this case. This is because the property of the data object is of type double. When a user enters some text, this value cannot be converted to a double, so the setter for this property is never reached. Therefore, I also cannot set any error properties. It seems the error message comes from some converter or something that lies between the textbox and the databound property.
One possible solution would be to create a separate string-type property for every double-type property, then bind the grid column to the string-type property instead and then synchronize values between these 2 properties. But that would require a huge amount of code (I have 200+ classes that would need this) and it certainly doesn't seem like a nice solution to the problem. The easiest solution would be to simply reset the resource string that I mentioned before. Maybe another alternative is to insert my own converter between the textbox and databound property if that would be possible. Any thoughts?
I have been looking into your sample and I believe that a similar question is already discussed here:
http://ko.infragistics.com/community/forums/p/76698/389100.aspx
Krasimir has attached a sample where he changed the default tooltip, when an error occurs in some of the cells.
Hope this helps you.