C#中的图像资源无法显示
我的一个WPF应用程序中,添加了一个32*32图像资源ImageLayerSize.png,通过下面的代码将该图像设置为某按钮的位图:
button = new RibbonButton();
button.Name = "SetLayerSize";
button.LargeImageSource = new BitmapImage(new Uri(@"Resources\ImageLayerSize.png", UriKind.RelativeOrAbsolute));
但是程序运行时,按钮始终没有出现图像显示。
经反复查找尝试,发现是图像文件ImageLayerSize.png的属性需要设置生成操作为Resource