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

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

问题描述

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



我想使用wpf主应用程序引用并显示图像。



任何想法?我想这样做在xaml不是代码背后,如果可能的话。



Ta,
Matt。

解决方案

假设您从WPF应用程序引用类库,您可以使用以下XAML引用并显示WPF应用程序中的映像:

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

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



您可以找到有关WPF包URI的更多信息 here


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.

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

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

Ta, Matt.

解决方案

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

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

You can find out more about WPF pack URIs here.

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

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