存储在外部DLL参考图像使用WPF [英] Reference images stored in external dll using wpf
问题描述
我有一个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的here 。
You can find out more about WPF pack URIs here.
这篇关于存储在外部DLL参考图像使用WPF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!