Search code examples
wpfimageresourcesembedded-resourcerelative-path

How to specify path to Image resources in WPF application


Below is in a flow document
I can see all 5 in design
When I run the program then none are found
How can I get relative path to work?

<Paragraph>
    <Image Width="50" Height="50" Source="zHelpMain.png" Stretch="Fill"/>
</Paragraph>
<Paragraph>
    <Image Width="50" Height="50" Source="Images\VennIntersection.png" Stretch="Fill"/>
</Paragraph>
<Paragraph>
    <Image Width="50" Height="50" Source="/Gabe2a;component/Images/VennUnion.png" Stretch="Fill"/>
</Paragraph>
<Paragraph>
    <Image Width="50" Height="50" Source="/Images/helpMain.png" Stretch="Fill"/>
</Paragraph>
<Paragraph>
    <Image Width="50" Height="50" Source="images\helpMain.png" Stretch="Fill"/>
</Paragraph>

enter image description here


Solution

  • Currently the image files are part of the solution, but not part of the project, so they're not embedded in the assembly when you compile. You need to add the to the Gabe2a project, with the build action set to "Resource".