locked
Image not getting displayed using FFImageLoading library RRS feed

  • Question

  • User308424 posted

    Please let me know what mistake am I doing in the following code:

    My Xaml Code:

    ffimageloading:CachedImage x:Name="postImage" ErrorPlaceholder="user.png" LoadingPlaceholder="user.png" HeightRequest = "50"

    My .cs Code:

    postImage = new FFImageLoading.Forms.CachedImage()
                                {
                                    HorizontalOptions = LayoutOptions.Center,
                                    HeightRequest = 50,
                                    WidthRequest = 50,
                                    Source = postAttachmentLink,
                                    Aspect = Aspect.AspectFill,
                                    LoadingPlaceholder = "user.png"
                                };
    

    Image is not getting displayed, just a blank space is getting displayed. I have added the forms package to both Droid and iOS projects and I have added the following line:

    CachedImageRenderer.Init();

    in MainActivity.cs of droid project and AppDelegate.cs of iOS project.

    Tuesday, March 14, 2017 9:43 AM

Answers

  • User37696 posted

    @kesh,

    Instead of using new for the postImage, set the properties on the control instead.

    postImage.Source = postAttachmentLink;

    Alternatively, you could all of this in XAML and not need the C# code at all.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, March 14, 2017 9:50 AM

All replies

  • User37696 posted

    @kesh,

    Instead of using new for the postImage, set the properties on the control instead.

    postImage.Source = postAttachmentLink;

    Alternatively, you could all of this in XAML and not need the C# code at all.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, March 14, 2017 9:50 AM
  • User308424 posted

    @JohnMiller I tried that code, It is giving me null reference exception after adding that piece.

    Sorry its not due to that.....

    Tuesday, March 14, 2017 11:43 AM
  • User308424 posted

    @JohnMiller Thank you it solved my problem

    Tuesday, March 14, 2017 11:49 AM