Refer to the image resource from the generic Universal App project

I just started working with winRT, collaborative projects, etc. and ran into some problems. I want to put all my resources (strings, images, etc.) into one project (portable class library or general project). When I put the image in PCL, everything works fine in xaml, referencing ms-appx:

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

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

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

Ok Then I decided to put all the resources in a common project. During this time, it works fine with strings, but not with images: I could not get the correct URI string in ImageSource ImageBrush.

So the questions are:

  • How to add ResourceDictionary in PCL

  • What is the correct URI format for linking to an image from a common project.

Thanks in advance!

+4
source share
1 answer

To access the image of your shared project file, simply use the direct path to the file.

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

Edited by @JerryNixon

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

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

<Image Source="ms-appx:///ProjectName/...path.../"/>
+11
source

All Articles