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

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

Thread ID:

Created:

Updated:

Platform:

Replies:

141124 Nov 26,2018 01:30 AM UTC Nov 27,2018 04:22 AM UTC Xamarin.Forms 3
loading
Tags: SfMaskedEdit
Lyndon Hughey
Asked On November 26, 2018 01:30 AM UTC

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);
}
}
}

Paul Anderson S [Syncfusion]
Replied On 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 


Lyndon Hughey
Replied On 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. 

Paul Anderson S [Syncfusion]
Replied On 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 


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

;