Show an Image resource in a WPF window defined in a class library

I have seen this thread: WPF image resources and applied the information there. But my situation seems a bit more tricky:

  • Assembly A is a class library
    • contains Dialog.xaml
      • this is a WPF window
    • contains Images/i.gif
  • Assembly B is a WPF application
    • shows Dialog.xaml

In my dialog, I have tried specifying the image in the following ways:

<Image Source="/Images/i.gif"/>

and

<Image Source="pack://application:,,,/Images/i.gif"/>

both work, but only in the designer!

Next, I added two and two together to yield:

<Image Source="pack://application:,,,A;;content/Images/i.gif"/>

but this shows the same symptoms:

As soon as I start the application, the images seem to be not found. I don't know for sure, since I get no error message. They just don't show up.

Any ideas?

Answers


You appear to be missing the required word "Component" form the beginning of your path, e.g.

pack://application:,,,/YourAssembly.Name;Component/Images/PlusGreen.png


Need Your Help

WheelView not found in Android

java android mobile

I downloaded a project from GitHub. When i tried to check its source its gives WheelView error.. WheelView is not importing in it..

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.