I have a WPF UserControl, which is using some PNG bitmap resources as part of it's UI. Currently, those files are referenced with Build Action: Content and a Copy to Output Directory: Do not copy. Elements on this UserControl are using following URI to access the resource:
pack://application:,,,Resources/ui/Cross.png
which works fine in designer.
The user control is then used in a Windows Forms application through ElementHost control at which point all image links stop working. The UserControl is in it's own assembly and Windows Forms application is referencing that assembly.
I have also tried changing the URI to this: pack://application:,,,Assembly.Name;component/Resources/ui/Cross.png
I have further tried reading this to no help.
The only option I have left is to include code to manually set ImageSource of all Image elements on the user control, which would require a lot of work. I feel like there must be a way to resolve this better.
That combination does not work.
Content
requires that the file is copied.However, you should use Build Action
Resource
. And your Pack URI misses a slash after,,,
.It should be
provided that the image file is part of your Visual Studio Project, located in a subfolder named
ui
in a project folder namedResources
.See Resource File Pack URIs for details.