Get relative path to image in another project in s

2019-07-04 23:26发布

问题:

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.

solution

-Project A

  -Helper.cs

-Project B

  -image.jpg

Helper.cs need a reference to image.jpg

I can't add a reference to prj A from prj B.

Can I do something like:

Uri uri = new Uri("/project.name.projectA;image.jpg", UriKind.Relative);

Thank you

回答1:

pack://application:,,,/ReferencedAssembly;component/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.

Resource File Pack URIs Referenced Assembly