我按照中的说明进行操作这本书 http://www.apress.com/book/view/9781430225492,关于资源等的章节,我不太明白的是,如何替换它:
images.Add(new BitmapImage(new Uri(@"/Images/Deer.jpg", UriKind.Relative)));
images.Add(new BitmapImage(new Uri(@"/Images/Dogs.jpg", UriKind.Relative)));
images.Add(new BitmapImage(new Uri(@"/Images/Welcome.jpg", UriKind.Relative)));
通过一个循环来简单地运行所有嵌入的图像资源,以避免对图像名称和路径进行硬编码。我将如何发现嵌入文件的名称?
我确实选择了要嵌入并指定的图像:
构建操作=资源并复制到输出目录=不复制
在属性窗口中。该组件的尺寸已大大增加,我非常确信图像确实已被嵌入。
尝试使用 GetManifestResourceNames 进行某些操作,或查看 ResourceManager 对象。
Assembly assembly = Assembly.GetExecutingAssembly();
foreach (string s in assembly.GetManifestResourceNames())
{
//match on filenames here. you can also extention matching to find images.
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)