WPF: Use a specific icon image in an Image element
How do I get a System.Windows.Controls.Image to use an image of a specified re开发者_运维问答solution and color depth from a .ico resource?
Create a BitmapFrame and use its Decoder. For example, to access a 48x48, 32-bit image:
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);
精彩评论