I have setup where Field is using a Converter to convert the bound value type to string. How do I handle exceptions in the Converter? If I throw the exception the application crashes.
For example, The field is bound to double and Converter is setup convert to string and vice-versa.
<igDP:Field Name="Salary" Label="Test salary" Converter="{StaticResource StringToDoubleConverter}">
I have attached the sample code to demonstrate the exception.
What I am interested to find out is
1. Is there some mechanism to handle exception and put the focus back to cell being edited?
2. Alternative to setup the Field where invalid inputs are handled more graciously.
To make the example represent more closer to my scenario I have updated the sample. Now I binding the field to Custom type MyDouble.
Attached the updated sample
HI Bhavesh,
If you need numeric data entry, then don't convert the double to a string. The XamDataGrid will use the XamNumericEditor for numeric data. This editor will not allow
nonnumeric data to be entered. Another option would be to wire up the XamDataGrid' EditModeEnding event and cancel it if the data is not in the correct format.
Here is a code snippet:
private void xgrid1_EditModeEnding(object sender, Infragistics.Windows.DataPresenter.Events.EditModeEndingEventArgs e)
{
if (e.Cell.Field.Name == "Address")
{ if (e.Editor.Text.Contains("z"))
e.Cancel = true;
}