我当时是按照学校的指示做的 this book ,关于资源等的章节,我不太清楚的是,如何替换这个:
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. }