使用项目资源(WPF)的图像源 [英] Image source using project resource (WPF)

查看:82
本文介绍了使用项目资源(WPF)的图像源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加了一堆图像作为项目资源。
现在我想在使用图像控件的WPF应用程序中使用它们。
如何将资源分配给图像控件的源?

I added a bunch of images as project resources. Now i want to use them in my WPF application using the image control. How can I assign the resource to the source of the image control?

推荐答案

首先,将图像文件标记为Visual Studio的属性窗口中的资源。然后,您可以使用文件名轻松引用资源:

First, mark you image file as a "Resource" in the properties window of Visual Studio. Then you can quite easily reference the resource using the file name:

<Image x:Name="image1" Source="theimage.png" />

如果您已将图像放入文件夹,则可以使用

If you have put your image in a folder, you can use

<Image x:Name="image1" Source="/folder/theimage.png" />

这篇关于使用项目资源(WPF)的图像源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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