DataFormRenderer not working on Android

3 posts, 0 answers
  1. Dominic
    Dominic avatar
    4 posts
    Member since:
    Jul 2016

    Posted 15 Jan Link to this post

    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. Didi
    Admin
    Didi avatar
    249 posts

    Posted 16 Jan Link to this post

    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
  3. Dominic
    Dominic avatar
    4 posts
    Member since:
    Jul 2016

    Posted 16 Jan in reply to Didi Link to this post

    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

     

     

     

Back to Top