FFImageLoading resetting binding?

LeloLelo Member ✭✭✭

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.

Answers

  • Amar_BaitAmar_Bait DZMember ✭✭✭✭✭
    edited December 2018

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

  • LeloLelo Member ✭✭✭

    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.

  • Amar_BaitAmar_Bait DZMember ✭✭✭✭✭

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

  • NMackayNMackay GBInsider, University mod

    @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.

  • NMackayNMackay GBInsider, University mod

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

    Well generally you should be using Binding in Forms.

  • LandLuLandLu Member, Xamarin Team Xamurai

    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.

Sign In or Register to comment.