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

Binding in Custom Renderer gives wrong value in Xamarin.Forms 1.3.4.6332

$
0
0

Hi folks,

I have a custom control inside ListView like this

public class VideoCustomView : View
{
        public VideoCustomView ()
        {
        }

        public static readonly BindableProperty FileSourceProperty = 
            BindableProperty.Create<VideoCustomView,string>(
                p => p.FileSource,string.Empty);

        public string FileSource {
            get { return (string)GetValue (FileSourceProperty); }
            set { SetValue (FileSourceProperty, value); }
        }
    }

and a custom renderer on iOS (*simplified just to check the value of FileSource )

public class VideoViewRenderer : ViewRenderer<VideoCustomView, View>
{
    protected override void OnElementChanged (ElementChangedEventArgs<VideoCustomView> e)
    {

        base.OnElementChanged (e);

        if (e.OldElement != null)
            return;

        string file = e.NewElement.FileSource;
        TextView lable = new TextView (Context);
        lable.Text = file.Substring (file.Length - 10);

        base.SetNativeControl (lable);

    }

}

I got random value that is totally different from itemsource, it was working fine in 1.3.1.6296

Anyone having this similar error?
Thanks,


Viewing all articles
Browse latest Browse all 58056

Trending Articles