WPF Icon for all app windows

A good reference on the subject is here MSDN. States that you have an Icon for the Application (Desktop Icon), and one for each Window.

A WPF window always displays an icon. When one is not provided by setting Icon, WPF chooses an icon to display based on the following rules:

  1. Use the assembly icon, if specified.

  2. If the assembly icon is not specified, use the default Microsoft Windows icon.

Community Content Reference:

"A liitle tip : if you set the application icon and expect to see it on the window - it wont show up if running in debug from VS. Running externally or without attaching (ctrl + f5) the icon displays as expected."


Set the icon in the project properties on the "Application" tab in the "Resources" section. This icon will be the default icon for all windows in the application.


Under VS2010 open the Properties for the main application executable and open the Application tab. Set the icon under 'Icon and Manifest' in the Resources section.

To see the icon while debugging under VS2010 you need to open the Debug tab and uncheck the option for 'Enable the Visual Studio hosting process', otherwise you will only see the default icon on most windows.

I assume that the icon loading code is getting confused by the hosting process and is looking in "someapplication.vshost.exe" instead of "someapplication.exe" for the icons.

This looks like it's fixed in VS2013.


The reason that "Enable the Visual Studio hosting process" makes the icon not work is that it is started using the vshost.exe, and thereby the manifest is not read properly. The same goes if you have other stuff in the manifest, like regfree ocx controls etc that requires the manifest to load.


You can also try this to set your own icon:

private void Page_Loaded_1(object sender, RoutedEventArgs e)
        {
            Uri iconUri = new Uri(@"C:\Apps\R&D\WPFNavigation\WPFNavigation\Images\airport.ico", UriKind.RelativeOrAbsolute);
            (this.Parent as Window).Icon = BitmapFrame.Create(iconUri);
        }