It is possible to set one Icon so, that it would be used on every window in current app. So that i set it once (not on every window by hand)..?
5 Answers
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:
Use the assembly icon, if specified.
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."

- 7,198
- 6
- 42
- 59
-
29One thing to be aware of (and it is mentioned in the "community content" section of the MSDN article you reference) is that the app still defaults to the default Windows icon when you run in debug mode from Visual Studio. This may be fixed in VS 2010, but I haven't checked. Just don't be too confused if you don't see your icon showing up when you debug! – Stephen Dec 10 '09 at 15:35
-
So how to specify then the icon in the assembly? – vts123 Dec 10 '09 at 16:08
-
3John let you know how to set the Assembly Icon. It's on the "Application" tab. You are probably running it in debug mode, which it will still show Windows Default Icon in debug. Build and run the executable from your bin folder. You should see the App Icon on all Windows. – jsmith Dec 10 '09 at 16:11
-
Ok, i compiled release version and executed exe file - now everything is ok. Thanks for good answer. – vts123 Dec 10 '09 at 16:19
-
I found that it depends on how the icon is defined. If it's set using the `Icon` property on the MainWindow, that it shows up, but if it's set in project resources, than it won't show up. – Ondrej Janacek Jul 25 '14 at 06:50
-
@ChrisMarisic See [RemAngel's](http://stackoverflow.com/a/21635926/806690) answer about the Visual Studio hosting process. – tm1 Sep 18 '14 at 11:40
-
1@tm1 i would call that a bug in VS2010 (2012?) seeing as it was fixed in 2013. – Chris Marisic Sep 18 '14 at 12:49
-
@ChrisMarisic I actually reproduced this with VS2013. Did it really work for you there? – tm1 Sep 18 '14 at 15:26
-
@tm1 no i didn't try anything, you referred me to RemAngel's answer and his answer says it was fixed in 2013. – Chris Marisic Sep 18 '14 at 15:32
-
2@tm1, I can not confirm that it is fixed in VS2013. Just ran into the same issue and the same workaround helped. – Daniel Albuschat Feb 20 '15 at 06:37
-
1@ChrisMarisic - re: `why wouldn't it show the icon when running in debug?` it _is_ showing the icon of the program that is running. But when you are debugging, the program it is running is called "vshost.exe" which contains the default icon. Then vshost runs your program in its debugging environment. If you want to think of it as a bug, then the bug is that vshost doesn't reflect the icon of the program begin debugged. – Jesse Chisholm Nov 16 '15 at 22:06
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.

- 12,076
- 4
- 31
- 44
-
1It doesnt work for me, i still see the default icon. I set the new icon as you said. – vts123 Dec 10 '09 at 15:55
-
19When you run in Debug mode you will not see your application icon. You need to run in Release mode or "Start Without Debugging" (Ctrl+F5) – John Myczek Dec 10 '09 at 16:26
-
Great tip -- this worked for me for my issue with the "pinned" icon as well. Sweet! – Dave Sep 11 '10 at 05:49
-
Good to know.....:) I didn't understand what's going on with that icon and how to set it to all the windows , but when I run in "Start Without Debugging" it works...:) – N.D Apr 05 '12 at 10:03
-
@John I set the icon in VS 2015 but it is still not working for me, not in Release nor in Debug not evern Start Without Debuggin – Khalil Khalaf May 16 '16 at 17:37
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.

- 1,963
- 1
- 15
- 14
-
1It's not fixed in VS2013, unfortunately. And btw., I too assume it has something to do with debugees running in a vshosts.exe process – Daniel Albuschat Feb 20 '15 at 06:38
-
1re: `why it doesn't show the icon when running in debug?` it _is_ showing the icon of the program that is running. But when you are debugging, the program it is running is called "vshost.exe" which contains the default icon. Then vshost runs your program in its internal debugging environment. If you want to think of it as a bug, then the bug is that vshost doesn't _reflect_ the icon of the program begin debugged. – Jesse Chisholm Nov 16 '15 at 22:07
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.

- 321
- 3
- 2
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);
}

- 117
- 14