How can I get a BitmapImage from a Resource?

江枫思渺然 提交于 2019-11-28 06:45:37

This MSDN page has all the information you might want to know about resource URIs in WPF (often called pack URIs). You're going to want to use relative URIs more often probably, so see Table 4, which should be of particular use.

If you want a briefer overview of resource (pack) URIs, see this blog post. It shows that syntax is indeed relatively simple:

pack://application:,,,/ResourceFile.xaml

pack://application:,,,/ReferencedAssembly;component/ResourceFile.xaml

However, there are a few quirks to work out (in my experience), so often finding the correct resource URI requires a bit of experimentation.

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