如何在WPF应用程序中指定Image资源的路径 [英] How to specify path to Image resources in WPF application

查看:130
本文介绍了如何在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".

这篇关于如何在WPF应用程序中指定Image资源的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆