WPF & Images
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've noticed a slightly strange behaviour of images on wpf forms used in Revit.
The scenario is the following:
I have a simple .NET solution, with a basic C# class library project and a shared project. If I add any png image in the shared project, into any folder, set its Build Action to Resource, and Copy to Output Directory to Do Not Copy, I can use this image on my wpf form with a simple
<Image Source="image_name.png"/>
xaml element, and it is visible both in visual studio and in Revit.
If I add the same image to the class library project with the same settings as before, I have to reference it in the xaml with the full relative path like
<Image Source="/path_to/image_name.png"/>
to make it show up in visual studio, but it will still not be visible in Revit.
So in the end if I have in the xaml:
<Image Source="image_in_shared_project.png"/>
<Image Source="\Resource\image_in_class_library_project.png"/>
both of them will be visible in visual studio, but only the first is visible in Revit.
Could someone please explain to me the reason and the mechanics of this behaviour? I would like to have the most optimal way to include image files in the built assembly, without copying png files over to the output directory..
Thanks!