在同一解决方案中获取另一个项目中图像的相对路径 [英] Get relative path to image in another project in same solution
问题描述
我的解决方案中有一个包含多个项目的 Silverlight 项目.我想得到一个相对路径到我的助手 C# 类中项目 B 中项目 A 中的图像.
I have a Silverlight project with several projects in my solution. I want to get a relative path to an image in project A from project B inside my helper C# class.
解决方案
-项目 A
-Helper.cs
-项目 B
-image.jpg
Helper.cs 需要对 image.jpg 的引用
Helper.cs need a reference to image.jpg
我无法从 prj B 添加对 prj A 的引用.
I can't add a reference to prj A from prj B.
我可以这样做吗:
Uri uri = new Uri("/project.name.projectA;image.jpg", UriKind.Relative);
Uri uri = new Uri("/project.name.projectA;image.jpg", UriKind.Relative);
谢谢
推荐答案
pack://application:,,,/ReferencedAssembly;component/ResourceFile.xaml
pack://application:,,,/ReferencedAssembly;component/ResourceFile.xaml
将 ReferencedAssembly 替换为引用程序集的名称,将 ResourceFile.xaml 替换为其中包含构建类型资源的文件的名称.
Replace ReferencedAssembly with the name of the referenced assembly and ResourceFile.xaml with the name of the file in it which has build type resource.
这篇关于在同一解决方案中获取另一个项目中图像的相对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!