Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refer an image resource from Universal App shared project

I just started work with winRT, shared projects etc. and faced with some problems. I want to put all of my resources (strings, images etc.) in one project (portable class library or shared project). When I put an image in PCL everything works fine in xaml by referencing with ms-appx:

<ImageBrush ImageSource="ms-appx:///Resources/Images/baby.jpg" Stretch="Uniform"/>

But when I put a string resource in PCL, I have following weird xaml behavior with ResourceDictionary:

http://postimg.org/image/ysbkvv6d7/

Ok. Then I decided to put every resources in Shared project. For this time it works perfectly with strings but fails with images: I couldn't get the right URI string in ImageSource of ImageBrush.

So the questions are:

  1. How can I add ResourceDictionary in PCL

  2. What is the correct URI format to reference image from shared project.

Thanks in advance!

like image 970
Serge P. Avatar asked Dec 15 '22 21:12

Serge P.


1 Answers

To access an image your shared project file, just use the direct file path. The

<Image Source="Assets/ImageName.png"></Image>

Edited by @JerryNixon

<Image Source="ms-appx:///Assets/ImageName.png"></Image>

To access an image in your PCL, use the longer syntax

<Image Source="ms-appx:///ProjectName/...path.../"/>
like image 92
Bryan Stump Avatar answered Jan 27 '23 03:01

Bryan Stump