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:
"C:/Users/me/AppData/Local/Packages/f040f23f-de21-4722-832d-7b617ef7fbe1_16fy7p00psw5z2/LocalState/se/resources/resources/plugins/spseplugin/myicon.png"
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:
- I have downloaded Nuget for FFImageLoading and it is added to my references
- In UWP App.xaml.cs, I added following as per FFImageLoading GitHub documentation instructions:
var assembliesToInclude = new List<Assembly>()
{
typeof(CachedImage).GetTypeInfo().Assembly,
typeof(CachedImageRenderer).GetTypeInfo().Assembly
};
Xamarin.Forms.Forms.Init(e, assembliesToInclude);
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:
CachedImageRenderer.Init();
Add xmlns namespace for FFImageLoading library in my XAML:
xmlns:ff="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms"
Add FFImageLoading CachedImage to my StackLayout:
<ff:CachedImage <-- using CachedImage wont show image. Using Image will show it.
Source="{Binding ImageUri}"
WidthRequest="20"
HeightRequest="20"
VerticalOptions="Center"
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.