I'm making a custom error dialog in my WPF app and I want to use a standard windows error icon. Can I get the OS-specific icon from WPF? If not, does anyone know where to get .pngs with transparency of them? Or know where in Windows to go extract them from?
So far my searches have turned up nothing.
Use this:
Don't forget to add System.Drawing reference to your project from global location.
Then use this in your xaml:
In Visual Studio, use File + Open + File and select c:\windows\system32\user32.dll. Open the Icon node and double-click 103. On my machine that's the Error icon. Back, right-click it and select Export to save it to a file.
That's the iffy way. These icons are also available in Visual Studio. From your Visual Studio install directory, navigate to Common7\VS2008ImageLibrary\xxxx\VS2008ImageLibrary.zip + VS2008ImageLibrary\Annotations&Buttons\ico_format\WinVista\error.ico. The redist.txt file in the Visual Studio install directly explicitly gives you the right to use this icon in your own application.
About using Standard Microsoft Icons.
The vast majority of developers out there don't know that Visual Studio comes with an Image Library. So here goes two links that highlight it:
About using Microsoft Visual Studio 2010 Image Library.
About using Microsoft Visual Studio 2008 Image Library.
use
SystemIcons
and convert them to anImageSource
like so:This is how I used a System icon in XAML:
I used this converter to turn an Icon to ImageSource:
There is a SystemIcons class, but it need adjustment for WPF needs (i.e. converting
Icon
toImageSource
).