The type of your Image property should be ImageSource , not Image , since you obviously want to bind the ImageCell ImageSource property. In addition, calling OnPropertyChanged on an OnPropertyChanged get properties never works because the PropertyChanged event must be fired before the binding (or any other consumer) can receive the changed value of the property.
Instead Image.Source="{Binding...} correct binding should be
<ImageCell ... ImageSource="{Binding Path=Image}" />
Properties must be declared like this:
private string imageBase64; public string ImageBase64 { get { return imageBase64; } set { imageBase64 = value; OnPropertyChanged("ImageBase64"); Image = Xamarin.Forms.ImageSource.FromStream( () => new MemoryStream(Convert.FromBase64String(imageBase64))); } } private Xamarin.Forms.ImageSource image; public Xamarin.Forms.ImageSource Image { get { return image; } set { image = value; OnPropertyChanged("Image"); } }
If you really need the lazy creation of Image property value, you could do it read-only, and make the corresponding OnPropertyChanged call in the ImageBase64 setter:
private string imageBase64 public string ImageBase64 { get { return imageBase64; } set { imageBase64 = value; OnPropertyChanged("ImageBase64"); OnPropertyChanged("Image"); } } private Xamarin.Forms.ImageSource image; public Xamarin.Forms.ImageSource Image { get { if (image == null) { image = Xamarin.Forms.ImageSource.FromStream( () => new MemoryStream(Convert.FromBase64String(ImageBase64))); } return image; } }
source share