从单独的程序集中访问图像文件

发布于 2024-10-08 08:19:01 字数 506 浏览 0 评论 0原文

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

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

我尝试了多种方式格式化 uri...但它从未成功。如果图标在实际装配中,但它们可以工作......

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>

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妖妓 2024-10-15 08:19:01

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

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

相对 Uri 也应该有效

<BitmapImage UriSource="/NameOfImageAssembly;component/Icons/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"/>

Relative Uri should also work

<BitmapImage UriSource="/NameOfImageAssembly;component/Icons/UserIcon.png"/>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文