Custom Renderer problem

i am trying to make a custom html renderer
it is working when i called it from datatemplate of listview
but when i am trying to use it in a custom label it won`t work
this is the code for the renderer
the "e.PropertyName " never came with "Text"

[assembly: ExportRenderer(typeof(HtmlLabel), typeof(HtmlLabelRenderer))]
namespace MobileApp.Droid.Renderers
    public class HtmlLabelRenderer : LabelRenderer
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName == Label.TextProperty.PropertyName)
#pragma warning disable CS0618 // Type or member is obsolete
                Control?.SetText(Html.FromHtml(Element.Text), TextView.BufferType.Spannable);
#pragma warning restore CS0618 // Type or member is obsolete

this is the code of the Custom view

public class HtmlLabel : Label

and this is the calling of the view

HtmlLabel htmlBody = new HtmlLabel();
htmlBody.SetBinding(Label.TextProperty, "body");
htmlBody.BindingContext = message;
htmlBody.Text = message.body;

both of them are not working


Best Answer


Sign In or Register to comment.