Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Bug in custom android's button renderer (XForm 1.3-pre3) ?

$
0
0

Hi,

While I was trying to do a custom button renderer for the XForms Lab's IconButton on Android, I came across a strange beheviour :
When I try to change the button text value, it is overwriten by the renderer :

public class IconButtonRenderer : ButtonRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Button> e)
        {
            base.OnElementChanged(e);
        Control.TextChanged += Control_TextChanged;
            Control.SetText("beer", TextView.BufferType.Normal); 
            Control.Text = "An other beer";
        }
        void Control_TextChanged(object sender, Android.Text.TextChangedEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine(e.Text.ToString());
        }
}

The SetText() method and the Text setter are overriden later by the original value, it can be easly checked with the Control.TextChanged event handler.

Is that the normal behaviour or is it a bug ?, and if it is normal where am I supposed to call Control.SetText() ?

Thx


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>