3

Exactly what it says in the title, I'd like to use a specific icon from imageres.dll as the application icon for my WPF program.

How can this be done?

Edit: I've manually extracted the icon from the DLL, but is there a easier / more 'correct' way to do this?

kiri
  • 2,522
  • 4
  • 26
  • 44

1 Answers1

2

It seems that WPF can't directly handle this.
But these links may help you to find your answer:

How do I use standard Windows warning/error icons in my WPF app?

Convert System.Drawing.Icon to System.Media.ImageSource

Do not forget to convert icon to Imagesource:

public static ImageSource ToImageSource(this Icon icon)
{
    ImageSource imageSource = Imaging.CreateBitmapSourceFromHIcon(
        icon.Handle,
        Int32Rect.Empty,
        BitmapSizeOptions.FromEmptyOptions());

    return imageSource;
}
Community
  • 1
  • 1
Zhr Saghaie
  • 1,031
  • 2
  • 16
  • 41