Share via

Image's Failed Loading

Anonymous
2021-12-25T00:42:35.493+00:00

Hi,

I have the following Image in my app:

<Image Source="{Binding gallery_image}" Aspect="AspectFill" IsLoading="{Binding Item, Mode=TwoWay}" />

but I want to check if the Image gallery_image was loaded or not, so if not then I want to show a default image.

Something similar to what ffimageloading provides.

How can I do that please?

Thanks,
Jassim

Developer technologies | .NET | Xamarin
0 comments No comments

2 answers

Sort by: Most helpful
  1. Chirag Pokiya 96 Reputation points
    2021-12-27T14:13:17.113+00:00

    @Anonymous

    Here is the sample code, you could refer to:

    <Image Source="{Binding ProfileImage, TargetNullValue=https://www.kindpng.com/picc/m/24-248253_user-profile-default-image-png-clipart-png-download.png}" />

    May I know whether your issue has been solved or not?

    Best Regards,

    Chirag Pokiya

    Was this answer helpful?

    0 comments No comments

  2. JarvanZhang 23,971 Reputation points
    2021-12-26T03:12:06.25+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    The FFImageLoading api provides the 'LoadingPlaceholder' property which can help to display a defalut image while loading.

       <ffimageloading:CachedImage   
           ...  
           LoadingPlaceholder = "loading.png"  
           Source = "url_source">  
    

    Xamarin.Forms.Image doesn't provide a property like 'LoadingPlaceholder', you could send a feature request to the product team on github repo at: https://github.com/xamarin/Xamarin.Forms/issues

    Here is a workaround for this feature. Try displaying two image at the same row of the a grid as below.

       <Grid>  
           <Grid.RowDefinitions>  
               <RowDefinition Height="Auto"/>  
           </Grid.RowDefinitions>  
           <Image Source="loading.png" HeightRequest="50"/>  
           <Image Source="source_url"/>  
       </Grid>  
    

    Best Regards,

    Jarvan Zhang


    If the response is helpful, 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.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.