locked
FFImageLoading resetting binding? RRS feed

  • Question

  • User372105 posted

    When I run the following code it works once. But the second time (with a correct url) the cached image is black. Why is that?

    public void Display(CachedImage cachedImage, SpecialImage displaySpecialImage) { cachedImage.RemoveBinding(SpecialImage.ImageUrlProperty); // remove previous binding cachedImage.BindingContext = displaySpecialImage; Binding binding = new Binding("ImageUrl"); binding.Source = displaySpecialImage.ImageUrl; cachedImage.SetBinding(CachedImage.SourceProperty, binding); }

    Due to some async loading operation I need to use binding. So I can't set the cachedImage.Source directly.

    Wednesday, December 12, 2018 2:41 PM

All replies

  • User74518 posted

    Show us your code, don't understand why you can't set Image.Source after your async call.

    Wednesday, December 12, 2018 2:49 PM
  • User372105 posted

    I have a serialised project file containing multiple imageurls. When deserialising I am using an async void method that checks if they are still valid urls and set them. When I use the display method, it displays before the check it completed.

    Wednesday, December 12, 2018 3:50 PM
  • User74518 posted

    But we need to see the code to help you, anything can go wrong in any step you mentioned.

    Wednesday, December 12, 2018 4:28 PM
  • User76049 posted

    @Lelo said: I have a serialised project file containing multiple imageurls. When deserialising I am using an async void method that checks if they are still valid urls and set them. When I use the display method, it displays before the check it completed.

    Post a repo, no one can help you with that little information.

    Wednesday, December 12, 2018 7:59 PM
  • User76049 posted

    "Due to some async loading operation I need to use binding"

    Well generally you should be using Binding in Forms.

    Wednesday, December 12, 2018 8:00 PM
  • User369979 posted

    I guess you maybe made a wrong usage of Binding. From your code above, you have set the cachedImage's BindingContext to displaySpecialImage, your binding should be like this:

    cachedImage.SetBinding(CachedImage.SourceProperty, new Binding("ImageUrl")); Do not set the source again. Apparently, if you could post a sample here, it could help us find your issues more easily and correctly.

    Thursday, December 13, 2018 2:31 AM