This is a migrated thread and some comments may be shown as answers.

DataFormRenderer not working on Android

2 Answers 134 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Dominic
Top achievements
Rank 1
Dominic asked on 15 Jan 2019, 10:37 AM

I am trying to implement a form that has a textbox. The textbox needs to have multi-line enabled. Using an example I have found from another thread on here I have managed to get this working on iOS but am struggling to get it to work on Android.

 

In the shared project I have added the following code to the form.

 

this.viewModel = new ViewModel();
this.BindingContext = this.viewModel ;

dataForm.RegisterEditor("MessageToSend", EditorType.Custom);
dataForm.Source = this.viewModel.Model;

 

Then in the Android project I have added the following code to MainActivity.cs

 

[assembly: ExportRenderer(typeof(RadDataForm), typeof(CustomDataFormRenderer))]
namespace Droid

{

  public class CustomDataFormRenderer : DataFormRenderer
    {
        public CustomDataFormRenderer(Context context) : base(context)
        {
        }

        protected override EntityPropertyEditor GetCustomEditorForProperty(RadDataForm form,
            IEntityProperty nativeProperty, Telerik.XamarinForms.Input.DataForm.IEntityProperty property)
        {
            if (property.PropertyName == "MessageToSend")
            {
                return  new DataFormMultilineTextEditor(form, nativeProperty);
            }
            return base.GetCustomEditorForProperty(form, nativeProperty, property);
        }
     }

}

 

If I place a breakpoint in the method GetCustomEditorForProperty() it never gets executed whch would seem to suggest that the custom editor is not configured correctly. But then it works perfectly on iOS, so it must be configured. 

 

 

 

 

2 Answers, 1 is accepted

Sort by
0
Didi
Telerik team
answered on 16 Jan 2019, 12:59 PM
Hello Dominic,

Thank you for the provided code.

I have tested the described scenario with the RadDataForm control when custom renderer is implemented on Android and I could not reproduce the issue. Could you please check the attached project how the custom renderers are implemented for iOS and Android? May I ask you to modify the project regarding your setup and send it back to me, so I could research it further? Please note that you should open a support ticket and attach it there because in the forum only image attachments are allowed.

Thank you in advance.

Regards,
Didi
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Dominic
Top achievements
Rank 1
answered on 16 Jan 2019, 03:04 PM

Hi Didi

I have resolved this now. I was using an incorrect reference to the type RadForm in my MainActivity.cs

[assembly: ExportRenderer(typeof(RadDataForm), typeof(CustomDataFormRenderer))]

I have fixed this and it all works now.

Kind regards

Dominic

 

 

 

Tags
DataForm
Asked by
Dominic
Top achievements
Rank 1
Answers by
Didi
Telerik team
Dominic
Top achievements
Rank 1
Share this question
or