Bindable Property is not working in content view for pass an uri

Andrea Ciullo 21 Reputation points

This is the scenario:

I have a ContentView with string bindable property for send an uri string and show an image.

the problem is, if i send an bindable string the property change isn't fires, but manualy it's fire correcty.

    public string ProductImageURL  
            get { return (string)GetValue(ProductImageUrlProperty); }  
            set { SetValue(ProductImageUrlProperty, value); }  
        public static readonly BindableProperty ProductImageUrlProperty = BindableProperty.Create(  
           propertyName: nameof(ProductImageURL),  
           returnType: typeof(string),  
           declaringType: typeof(ProductCardHorizontal),  
           defaultBindingMode: BindingMode.TwoWay,  
           propertyChanging: ImageUrlChanged  
        private static void ImageUrlChanged(BindableObject bindable, object oldValue, object newValue)  
            if (bindable != null && newValue != null)  
                var control = (ProductCardHorizontal)bindable;  
                control.productImage.Source = (string)newValue;  

This call dont work

                                   ProductImageURL="{Binding Item.ImageURL}"  

And if i put some url it's work

A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,261 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 64,576 Reputation points Microsoft Vendor


    Do you use <contentViews:ProductCardHorizontal> in ListView or CollectionView? And you have list in the ViewModel like following code.

       public List<Item> lists { get; set; }  

    If so, please binding ImageURL directly, remove Item like following xaml.

                                       ProductImageURL="{Binding ImageURL}"  

    If not, please share your layout code. And add an breakpoint in control.productImage.Source = (string)newValue; line, check if you get value from binding property.

    Best Regards,

    Leon Lu

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

0 additional answers

Sort by: Most helpful