I have a string field called Withholdingtaxes with 2 possible value "S" and "N".
I do use this converter to make it bool :
[Converter(typeof(SNBooleanConverterExt))]
public string Withholdingtaxes { get; set; }
public class SNBooleanConverterExt : IPropertyValueConverter
{
public object Convert(object value)
{
return (bool)(value.ToString().Equals("S"));
}
public object ConvertBack(object value)
{
return (bool)value ? "S" : "N";
}
}
I want to show it as a "Switch" :
dataForm.RegisterEditor("Withholdingtaxes", "Switch");
My DataForm is by default ReadOnly. And It seems to be working as expected.
But, when I click on the Edit Button, I call this code :
dataForm.IsReadOnly = false;
dataForm.RefreshLayout();
And now I got this error :
System.InvalidCastException: 'Unable to cast object of type 'System.String' to type 'System.Boolean'.'
It seems to be ignoring the converter when I call RefreshLayout();
How can I fix this?