Jerry Nixon
Jerry Nixon

Reputation: 31813

In WinRT XAML, how to reference images in outside/separate assembly/project?

Seems to be different in WinRT (Windows 8). Anyone figure it out yet?

My experiments.

Of course:

File Build Action == Content && Copy to Output Directory == Copy always

These don't seem to work:

<Image Source="Folder/file.jpg" />
<Image Source="/Folder/file.jpg" />
<Image Source="Namespace;Folder/file.jpg" />
<Image Source="Namespace;/Folder/file.jpg" />
<Image Source="pack://Namespace;Folder/file.jpg" />
<Image Source="pack://Namespace;/Folder/file.jpg" />

Out of desperation I tried:

File Build Action == Embedded Resource && Copy to Output Directory == Copy always

Still fail. Ugh!

Upvotes: 9

Views: 6601

Answers (1)

JP Alioto
JP Alioto

Reputation: 45117

<Image Source = "ms-appx:///<projectName>/<folderName>/<contentName>" />

For example ...

<Image Source = "ms-appx:///ClassLibrary1/Content/myimage.png" />

See How to Reference Content for a bit more info.

Upvotes: 15

Related Questions