We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Problem using Converter with DataForm

Thread ID:

Created:

Updated:

Platform:

Replies:

143316 Mar 13,2019 07:25 PM UTC Mar 27,2019 11:16 AM UTC Xamarin.Forms 4
loading
Tags: SfDataForm
Cezar
Asked On March 13, 2019 07:27 PM UTC

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?




Deivaselvan Y [Syncfusion]
Replied On March 14, 2019 12:26 PM UTC

Hi Cezar, 
 
Thank you for contacting Syncfusion support. 
 
Currently, we are analyzing the reported behavior “InvalidCastException throws while using converter to convert from string to bool for SwitchEditor” in source and sample level, we will update you for this in two business days on 18th March 2019. We appreciate your patience until then. 
 
Regards,
Deivaselvan 


Deivaselvan Y [Syncfusion]
Replied On March 18, 2019 12:19 PM UTC

Hi Cezar, 
 
Thank you for your patience. 

We can reproduce the reported issue “InvalidCastException throws while using converter to convert from string to bool for SwitchEditor”. Currently, we are validating the issue in both source and sample level, and we will update the details for the same in two business days on 20th March 2019. We appreciate your patience until then. 

Regards,
Deivaselvan 


Deivaselvan Y [Syncfusion]
Replied On March 20, 2019 12:21 PM UTC

Hi Cezar, 
 
Thank you for your patience. 
 
We can reproduce the reported issue “InvalidCastException throws while using converter to convert from string to bool for SwitchEditor” and we have logged an issue report for the same, we will update you with patch for this issue fix on or before 27th March 2019. We appreciate your patience until then. Now You can now track the status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link. 
 
 
Kindly revert us if you have any other questions. 
 
Regards, 
Deivaselvan 


Deivaselvan Y [Syncfusion]
Replied On March 27, 2019 11:16 AM UTC

Hi Cezar, 
 
Thank you for your patience. 
 
We have fixed the mentioned issue “InvalidCastException throws while using converter to convert from string to bool for SwitchEditor” and the patch for the issue fix is following by. 
 
Set Up: 
 
Custom Assemblies: 
 
Nuget: 
 
Kindly find the below link to clear Nuget cache,
https://www.syncfusion.com/kb/6987/how-to-clear-nuget-cache    
    
Installation Direction:       
{Syncfusion Installed location}\Essential Studio\16.4.0.52\Xamarin\lib\pcl\Syncfusion.SfDataForm.XForms.dll             
{Syncfusion Installed location}\Essential Studio\16.4.0.52\Xamarin\lib\android\Syncfusion.SfDataForm.XForms.Android.dll             
{Syncfusion Installed location}\Essential Studio\16.4.0.52\Xamarin\lib\android\Syncfusion.SfDataForm.XForms.iOS.dll             
{Syncfusion Installed location}\Essential Studio\16.4.0.52\Xamarin\lib\android\Syncfusion.SfDataForm.XForms.UWP.dll            
     
     
Disclaimer:     
Please note that we have created this patch for version 16.4.0.52 specifically to include the issue reported in Forum 143316, we will include this fix in our upcoming Volume 1 main release, which is expected to roll out at the end of March 2019. 
    
Please let us know if you need further assistance.    
 
Regards,    
Deivaselvan 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;