This web site uses cookies. By using the site you accept the cookie policy.This message is for compliance with the UK ICO law.

Windows Presentation Foundation
.NET 3.0+

Setting a WPF Application's Icon

All Windows-based applications include an icon that is displayed when the application's file is shown in Explorer and similar tools. For WPF applications, a default application icon is applied, unless changed in the project.

Application Icons

All Windows executables include an application icon that is displayed when the file is viewed in Explorer, other file tools and some standard dialog boxes that work with the file system. The application icon is also used as the default option for shortcuts to the program, such as those in the Start menu and task bar.

When you create a WPF application, a default icon is applied to the compiled executable. An example icon is shown below.

WPF application default icon

This icon is unlikely to represent your software and can be confusing if used for multiple applications. It is advisable to always change the icon and use a different image for each program that you create.

Icon Files

The application icon can be set using any icon file. These are files with the "ico" extension. Each file contains a minimum of one image. However, it can hold multiple images, each with a different size or number of colours. When an icon must be displayed, the operating system uses the most appropriate image, according to the size required and the number of colours available in the current screen mode.

The suggested image sizes to include in all icon files are 16x16, 32x32, 48x48 and 256x256 pixels. This gives a wide range of images from which the operating system can select. When other sizes are needed, the stored images from the file will be resized automatically. Each of these images should be created using 32-bit colour, with 8 bits each for red, green, blue and alpha channels. This allows for partial transparency.

Ideally, additional images for the three smaller sizes should also be created using colour depths of 256 colours and 16 colours. These versions will be used if the system is configured with fewer available colours. If the icons are not present, the 32-bit versions will be used but may require dithering, which can reduce image quality.

The four sizes above should give acceptable quality output for most cases. You can, however, add further sizes to ensure that the reproduction is good in all situations. Other standard sizes used by Microsoft Windows are square images with dimensions of 8, 10, 14, 22, 24, 40, 64, 96 and 128 pixels.

Setting the Application Icon

Choosing the application icon for a WPF project is simple. Firstly, you need to access the project's property pages, using the "Properties" option from the "Project" menu, or by right-clicking the project name in the Solution Explorer and choosing "Properties" from the context-sensitive menu that appears.

With the properties visible, select the "Application" tab and locate the "Resources" section. This includes a text box that shows the name of the current application icon. To the right is a button, labelled with an ellipsis (...). Clicking this button allows you to browse the file system and choose an icon file.

Once an icon is selected, its file name appears in the Icon textbox and a representation of the icon appears to the right of the button. The file's details are recorded in the WPF project file and the icon is embedded into the executable when the project is next built.

WPF application default icon

21 October 2015