Venkat Ramanan
Venkat Ramanan

Reputation: 217

WPF Accessing image path from shared project

I have a WPF application (Project A) in which i have a Resource Dictionary file Global.xaml. In this file i am refering

<BitmapImage x:Key="Test" UriSource="..\Images\Test.png">

The above line references the image from the below path

pack://application:,,,/Assembly of Project A;component/Images/Test.png

Now i am moving the image to a Shared project (Shared Project A) and is referenced in Project A. So what would be UriSource?

I tried giving Assembly of Shared Project A;component/Images/Test.png

but it is not taking the image from shared project.

Upvotes: 2

Views: 1275

Answers (1)

Felix D.
Felix D.

Reputation: 5093

Try this:

General:

Source="pack://application:,,,/<ReferencedAssemblyName>;component/<PathInReferencedAssembly>"

In your case:

Source="pack://application:,,,/SharedProjectA;component/Images/Test.png"

Also make sure the Build-Action is Resource for all of your Images and the project is built successfully.

Upvotes: -1

Related Questions