我有一个wpf应用程序,我必须动态添加图像资源。各自的代码如下。
public class ImageNames
{
static string path = @"pack://application:,,,/" + Assembly.GetExecutingAssembly().GetName().Name + ";component/Images/";
public static BitmapImage TickImage = new BitmapImage(new Uri(path + "icon_tick.gif", UriKind.Absolute));
public static BitmapImage CrossImage = new BitmapImage(new Uri(path + "icon_cross.gif", UriKind.Absolute));
public static BitmapImage DeleteImage = new BitmapImage(new Uri(path + "icon_delete.gif", UriKind.Absolute));
}
使用Build Action = Resource
将图像添加到相应的程序集中。但是在创建BitmapImage为Provide value on 'System.Windows.Markup.StaticExtension' threw an exception.