WPF C# Unable to find subfolder image resource

╄→гoц情女王★ 提交于 2019-12-11 14:28:56

问题


I have several images in an assembly that I have all marked as resource in their property setting.

For testing I put an image at the root of my project.

Img.Source = new BitmapImage(new Uri("pack://application:,,,/MyAssembly;component/image.png", UriKind.Absolute));            

and it finds and loads the image just fine.

If I place the image in a subfolder no matter what folder or what level, it returns back that it is unable to find the resource.

The folder structure is Resources/Base/Weather/image.png

Img.Source = new BitmapImage(new Uri("pack://application:,,,/MyAssembly;component/Resources/Base/Weather/image.png", UriKind.Absolute));            

When I run the application and try to load that image I get this error

Cannot locate resource 'resources/base/weather/image.png'.

Notice the lowercase on the folder names. I am at a loss as to what to try next. I have tried many variations including using the @ but that doesn't help. I really do not want to load up the root directory with images.

Thoughts Anyone???

来源:https://stackoverflow.com/questions/14493106/wpf-c-sharp-unable-to-find-subfolder-image-resource

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!