An .xaml image location in a secondary reference is not becoming the correct resource location during runtime, it refers to the primary reference resources folder instead. How can I change this?
Background -
I have a solution with several projects. The important three projects here are
- a WPF project which builds as a class library
- a default class library
- a console app for testing
The WPF project has a .png image in its resources. In the MainWindow created it's called via:
<ImageBrush
ImageSource="pack://siteoforigin:,,,/Resources/MyDemoImage.png"
Stretch="Uniform"/>
When I run an instance of the WPF window directly through the console app, it works fine. The resource reference becomes during runtime:
C:\Users\me.me\Documents\Visual Studio 2015\Projects\sol\
WPFProjectName\
bin\Resources\MyDemoImage.png
But if I create a reference to the WPF project within the class library project then call an instance of the class library, the address becomes
C:\Users\me.me\Documents\Visual Studio 2015\Projects\sol\
ClassLibraryName\
bin\Resources\MyDemoImage.png
So this "pack" address becomes a reference to the class library resources rather than the WPF project resources folder.
Now, I think I could simply add the resource to that middle-man class library too, but I'm wondering if there's some correct way to reference a "secondary" resource, so I only have to add images once?
By the way, the error I get when I try to compile this is System.Windows.Baml2006.TypeConverterMarkup - I've found answers regarding this but tried what they say to no avail (mark image as copy always etc.)