使用 wpf 存储在外部 dll 中的参考图像 [英] Reference images stored in external dll using wpf

查看:25
本文介绍了使用 wpf 存储在外部 dll 中的参考图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 wpf 应用程序和一个类库(dll)项目.在我的 dll 中,我有一个图像文件夹,其中一些 .png 文件设置为资源.

I have a wpf application and a class library(dll) project. In my dll I have an images folder with some .png files set as Resource.

我想使用 wpf 主应用程序引用和显示图像.

I want to reference and display the image using the wpf main application.

有什么想法吗?如果可能的话,我想在 xaml 中执行此操作而不是后面的代码.

Any ideas? I want to do this in the xaml not the code behind if at all possible.

塔,马特.

推荐答案

假设您从 WPF 应用程序引用类库,您可以使用以下 XAML 在 WPF 应用程序中引用和显示图像:

Assuming you reference the class library from the WPF application you can reference and display the image in the WPF application with the following XAML:

<Image Source="/ClassLibraryName;Component/images/myimage.png"/>

这里重要的是ClassLibraryName",它是您的类库的程序集名称./images/myimage.png"是您的图片的路径.

The important thing here is "ClassLibraryName" which is the assembly name for your class library. "/images/myimage.png" is the path to your image.

您可以找到有关 WPF 包 URI 的更多信息 此处.

You can find out more about WPF pack URIs here.

这篇关于使用 wpf 存储在外部 dll 中的参考图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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