类库中usercontrol中的资源图像未显示在主应用程序WPF中 [英] Resource image in usercontrol in class library not displaying in the main application WPF

查看:411
本文介绍了类库中usercontrol中的资源图像未显示在主应用程序WPF中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有用户控件的类库项目。我已将图像文件夹添加到类库中,并在同一项目中使用用户控件中的图像。现在在主wpf项目中添加用户控件。但图像没有显示。 I
创建了一个具有相同流程的示例应用程序。

I have a class library project with user controls. I have added the image folder to the class library and using the image in the user control in the same project. and now adding the user control in the main wpf project. but the image is not displaying. I created a sample application with same flow there it is working.

Source =" pack:// application:,,, / Images / FolderImages / down.png"

Source="pack://application:,,,/Images/FolderImages/down.png"


我得到了一个参考:  https://social.msdn.microsoft.com/Forums/vstudio/en-US/8caa8ef7-ae9e-47f5-b8f7-a93d5438c6a1/how- to-use-resources-images-in-dll-assembly?forum = wpf


但是如何设置dll构建动作。我正在添加库项目作为我的主要wpf项目的参考。

But how to set dll build action. i am adding the library project as reference to my main wpf project.

推荐答案


使用以下格式解决。

Got solved by using the below format.


Source =" / CustomControls; Component / Images / FolderImages / down.png"

Source="/CustomControls;Component/Images/FolderImages/down.png"


参考
使用wpf存储在外部dll中的图像


这篇关于类库中usercontrol中的资源图像未显示在主应用程序WPF中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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