2

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.

Marc
  • 17,042
  • 6
  • 41
  • 46
Venkat Ramanan
  • 187
  • 1
  • 7
  • Related question in case you run into trouble with this: [*Pack URI to image embedded in a resx file*](https://stackoverflow.com/q/16409819/109702) – slugster Jan 23 '18 at 09:02

1 Answers1

0

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.

Felix D.
  • 4,417
  • 6
  • 37
  • 68
  • 1
    This solution does not work for me, it throws `FileNotFoundException` because it is trying to find `SharedProjectA` assembly, but such assembly does not exist because shared projects do not create own assemblies. I am playing with almost empty solution and I have a strange problem: I have an image in folder `SharedProject/Images/image.png`. When I reference it as `/Images/image.png` it correctly shows up in designer, but not in runtime. On the other hand when I reference it without path as `image.png`, it does not show in designer, but works in runtime :( – klasyc Mar 16 '21 at 12:19