如何在WPF应用程序中指定Image资源的路径

如何在WPF应用程序中指定Image资源的路径

问题描述:

下面是流程文档

我可以看到设计中的所有5个

当我运行程序时,没有找到任何东西

我怎样才能得到相对工作路径?

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>

目前,图像文件是解决方案的一部分,但不是项目的一部分,因此在编译时它们不会嵌入到程序集中。您需要将构建操作设置为资源添加到Gabe2a项目。

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".