从分离的程序集中访问图像文件 [英] accessing image files from a separated assembly

查看:50
本文介绍了从分离的程序集中访问图像文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个我想在项目之间共享的图像文件(通用图标)我将它们放在我创建的每个解决方案中的程序集中...我有一个名为 Icon 的文件夹中的文件,我的构建为始终复制内容.我已经验证使用这些图标创建了一个文件夹...但是我的其他程序集无法找到它们...

I have several image files I want to share between projects(common icons) I have them in an assembly that would be in every solution I create...I have the files in a folder called Icon and I have the build as content copy always. I have verified that a folder is created with these icons...however my other assemblies are not able to find them...

<r:RibbonGroup Header="Users">
    <r:RibbonButton >
       <r:RibbonButton.LargeImageSource>
            <BitmapImage UriSource="..\Icons\UserIcon.png" />
       </r:RibbonButton.LargeImageSource>
    </r:RibbonButton>
</r:RibbonGroup>

我尝试了多种方式格式化 uri...但它从未成功.如果图标在实际程序集中虽然它们有效...

i have tried formatting the uri several ways...but it never succeeds. If the icons are in the actual assembly though they work...

推荐答案

尝试使用绝对 Uri.构建操作必须设置为 UserIcon.png 的资源

Try using an absolute Uri. Build action must be set to Resource for UserIcon.png

<BitmapImage UriSource="pack://application:,,,/NameOfImageAssembly;component/Icons/UserIcon.png"/>

相对 Uri 也应该有效

Relative Uri should also work

<BitmapImage UriSource="/NameOfImageAssembly;component/Icons/UserIcon.png"/>

这篇关于从分离的程序集中访问图像文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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