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. Image for the cookie policy date

SfMaskedEdit - How to extend the renderer? Oddly not working..

I'm looking to add a border around my SFMaskedEdit on the Android platform of my project, but I'm unable to extend the SFMaskedEditRenderer. I can't evento hit a breakpoint within the code below, which tells me I'm not properly overriding the base class. Could you show me how to extend the control, or what I'm missing? I've looked over the code at least 10x. Is there something within the control that is preventing it from being overriden? Thanks.

The code that I'm using is below

using Android.Content;
using Android.Graphics.Drawables;
using ProjectName.Droid.Renderers;
using Syncfusion.XForms.Android.MaskedEdit;
using Syncfusion.XForms.MaskedEdit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;

[assembly: ExportRenderer(typeof(SfMaskedEdit), typeof(CustomSFMaskedEditRenderer))]
namespace ProjectName.Droid.Renderers
{
public class CustomSFMaskedEditRenderer : SfMaskedEditRenderer
{

public CustomSFMaskedEditRenderer() : base(){}

protected override void OnElementChanged(ElementChangedEventArgs e)
{
base.OnElementChanged(e);

if (e.OldElement != null) return;
UpdateEntryStyle();
}

void UpdateEntryStyle()
{
var shape = new GradientDrawable();
shape.SetShape(ShapeType.Rectangle);
shape.SetCornerRadius(5);

shape.SetStroke(3, Android.Graphics.Color.LightGray);
shape.SetColor(Android.Graphics.Color.White);
this.Control.SetBackground(shape);
this.Control.SetPadding(8, 15, 8, 0);
}
}
}

3 Replies

PA Paul Anderson S Syncfusion Team November 26, 2018 11:10 AM UTC

Hi Lyndon Hughey, 
 
Greetings from Syncfusion. 
 
We have checked your requirement from our side. We have created a sample with the provided code snippet. In this sample we have to create a CustomMaskedEdit in Forms and have to use CustomMaskedEdit instead of SfMaskedEdit directly as typeof in ExportRenderer at CustomSFMaskedEditRenderer to achieve the requirement. Please find the sample from below link. 
 
 
Regards, 
Paul Anderson 



LH Lyndon Hughey November 26, 2018 01:00 PM UTC

You sample is great.  Thanks for that. I'm not why I couldn't complete the implementation in the renderer and override all instances like I wanted to below. It looks like I'll be using your form of implementation. 


PA Paul Anderson S Syncfusion Team November 27, 2018 04:22 AM UTC

Hi Lyndon Hughey, 
  
Thanks for the update. We are glad that your requirement has been achieved with the sample we have provided. Please get in touch if you required further assistance. 
  
Regards, 
Paul Anderson 


Loader.
Live Chat Icon For mobile
Up arrow icon