如何让 System.Windows.Controls.Image 使用 .ico 资源中具有指定分辨率和颜色深度的图像?
最佳答案
创建一个 BitmapFrame 并使用它的解码器。例如,要访问 48x48、32 位图像:
BitmapFrame icon = BitmapFrame.Create(new Uri("pack://application:,,,/Resources/Icon.ico", UriKind.Absolute));
BitmapFrame image = icon.Decoder.Frames.First(f => f.PixelHeight == 48 && f.Format.BitsPerPixel == 32);
关于WPF:在图像元素中使用特定的图标图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4196239/