Forum Xamarin.Forms

FFImageLoading is Not Loading Image From App Sandbox in Xamarin.Forms UWP

dinobdinob USUniversity ✭✭✭

I am using a Xamarin.Forms UWP app that has image "myicon.png" downloaded to its sandbox location. It's path is like below and I can see it and in Windows Explorer and open the image in MS Paint for example. That prooves that the image exists in the App Sandbox:

So, the image is not added to project structure (neither PCL nor UWP) but it is available in the app sandbox location.

I am trying to load that image and show it in StackLayout in my UWP app using FFImageLoading library for performance reason as it does image caching. In order to do so, I am doing following:

  1. I have downloaded Nuget for FFImageLoading and it is added to my references
  2. In UWP App.xaml.cs, I added following as per FFImageLoading GitHub documentation instructions:
                        var assembliesToInclude = new List<Assembly>()
                        Xamarin.Forms.Forms.Init(e, assembliesToInclude);
  1. In my UWP MainPage.xaml.cs, I added following line in MainPage c-tor just after call to InitializeComponent, also as per FFImageLoading GitHub instructions:

  2. Add xmlns namespace for FFImageLoading library in my XAML:

  3. Add FFImageLoading CachedImage to my StackLayout:

        <ff:CachedImage       <-- using CachedImage wont show image. Using Image will show it.
          Source="{Binding ImageUri}" 
          DownsampleToViewSize="True" />

Above, ImageUri is a property on my view-model and putting break point on it shows that it is set to the image file path I showed above.

Using FFImageLoading CachedImage however is not showing the image when I run my app whereas Image (Xamarin Image View) is showing it fine.


  • dinobdinob USUniversity ✭✭✭
    edited September 2017

    UPDATE to the above question
    @DanielL Provided the link to github repo for FFImageLoading library ImageSourceConverter

    Interesting finding here. This converter implements TypeConverter and if I use it like this

    <ff:CachedImage Source="{Binding ImageUri, Converter={StaticResource imageSourceConverter}}" 
      WidthRequest="30" HeightRequest="30" VerticalOptions="Center" 
      DownsampleToViewSize="True" />

    , it will crash with error "Cannot assign property "Converter": Property does not exists, or is not assignable, or mismatching type between value and property".

    I copied the code for this converter into my own class and it would still crash with same error. And it does so even before it hits the break point I placed in there.

    But then, I changed it to implement IValueConverter instead of TypeConverter and implemented Convert() method from IValueConverter instead the CanConvertFrom and ConvertFrom from TypeConverter, I removed Preserve and Obsolete attributes. I moved code from ConvertFrom to the Convert method and it started working fine and image is being displayed.
    @DanielL Any comment on this? Thank you

  • dinobdinob USUniversity ✭✭✭
    edited September 2017

    .... and if I use above TypeConverter the way TypeConverter should be used like:

        <ff:CachedImage Source="{Binding ImageUri}" 
          WidthRequest="30" HeightRequest="30" VerticalOptions="Center" 
          DownsampleToViewSize="True" />

    and adding TypeConverter to my ImageUri property like in screenshot below, I would get that TypeConverter is not available in UWP :(

  • DanielLDanielL PLInsider ✭✭✭✭

    @dinobuljubasic TypeConverter is a Xamarin.Forms class. You either have some corrupted Xamarin.Forms installation or some missing references problem.

  • dinobdinob USUniversity ✭✭✭
    edited September 2017

    @DanielL I am seeing this problem happening to quite few people outthere when dealing with UWP. I understand it is Xamarin.Forms class but it is not supported in UWP and there is nothing telling me how to resolve it nor suggesting a missing reference or corrupt installation.
    I installed Xamarin.FFImageLoading.Forms nuget on my entire solution. Thanks

  • DanielLDanielL PLInsider ✭✭✭✭

    @dinobuljubasic Nice research. I'm not using Windows a lot. Do you have any suggestions how could we fix this? Xamarin's Image uses TypeConverter class in every platform. Maybe you could create an issue on our github page?

    BTW: you're missing Xamarin.FFImageLoading.Svg package.

  • dinobdinob USUniversity ✭✭✭

    @DanielL I already created an issue at github ( and I updated to show what exactly was added by Nuget Package Manager on solution level.

  • YogeshhJunejaYogeshhJuneja INMember ✭✭
    edited December 2017

    <ffimageloading:CachedImage Aspect="AspectFill" WidthRequest="50" HeightRequest="50" Source="{Binding Source=url}" DownsampleToViewSize="true"></ffimageloading:CachedImage>

    Image is not showing and if i use normally Image tag then my app crashes , i am showing images in listview

  • DanielLDanielL PLInsider ✭✭✭✭

    @YogeshhJuneja I'll need some more info / code.

Sign In or Register to comment.