0

I am trying to use FFImageLoading in a ListView using only XAML and a view model. For each item in the list i have a model and I want to trap when an image fails to load and update a label thats associated with the image in the same model.

<ffimageloading:CachedImage
        DownsampleToViewSize="true"
        RetryCount="0"
        ErrorCommand="{Binding ImageLoadError}"
        IsVisible="{Binding HasAttachement}"
        Source="{Binding Attachment}">
</ffimageloading:CachedImage>

I thought adding an ErrorCommand handler thats bound in my model would work except the command is being invoked for every instance of my model and not just the instance where the image loading fails

ImageLoadError = new Command((e) =>
{
   Debug.WriteLine($"Image load error Text is {Text}");
});

The above command handler is invoked for every instance of my model and not just the instance attached to the failed image.

How can i get notifications of loading errors to only the instance of my model thats associated with the image?

Peter Haddad
  • 78,874
  • 25
  • 140
  • 134
user1371314
  • 762
  • 7
  • 24

1 Answers1

0

As you can see on the FFImageLoading Wiki/Documentation at the Events section (FFImaleLoading Events) there is an event for 'Errors' on which you can listen to.

Error

Occurs after every image loading error. Returns: Exception

Try to subscribe to this event and it should return only those instances which cannot be loaded.

Community
  • 1
  • 1
MalokuS
  • 446
  • 3
  • 12