It appears you've figured this out, but for a PCL to support AppX resources, it needs to exclusively target platforms which support AppX resources. Right now that means Windows 8.1 and Windows Phone 8.1.
Images loaded from Portable Class Library
Pergunta
I have a Windows Store App that has many, many images in it. Further, these images need to be access in multiple projects on multiple plaftorms.
I had created a class library specifically targetting WinRT. This worked well and I was able to access the images using the Uri: "ms-appx:///MyImageClassLibrary/PathToImage/ImageName.png"
.
The beautiful part of this was that I could have my images sorted by scale similar to how I would in the local assets themselves, via a folder structure such as
/Images
/scale-100
Image1.png
/scale-140
Image1.png
/scale-180
Image1.png
/scale-80
Image1.png
Unfortunately, when I retargeted the library to a PCL (targeting Profile 259), This functionality broke. I now have to manually refer to the same image as "ms-appx:///MyImageClassLibrary/PathToImage/scale-100/ImageName.png"
.
Is there a way to fix this? Must I target the library to specifically WinRT? If I do target the library to WinRT, can that include Windows Phone 8.1? Will Windows Phone 8.1 be able to process the differently-scaled images?
Based on my intuition, I think I'll likely have to make a different image library for each platform. If this is the case, is there a way to auto-generate or link a subsequent class library targeted at another platform (such as Xamarin.iOS/Xamarin.Android) that copies all files in a given folder of the base project (such as all of them in scale-100
). I know that I can link files manually, but can I link folders so that any updates to the canonical project are reflected in platform-specific projects?
I will be experimenting more with this process, and will update here with any information I find.
Thanks.
Updates:
The scaling and direct reference work just fine with both Windows 8.1 and Windows Phone 8.1 targetted.
Solução