How to assign Application Icon that will display in Task bar?
Asked Answered
T

6

47

I am working on a Wpf desktop application, whenever i run my application it shows me a window and associated tab in the task bar(Normal windows feature). My problem is that the tab is using window's icon for unknown file-type, I tried with Icon property of Window, Icon gets assigned but still problem is when I run application, task bar Tab initially displays window's icon for unknown file-type and when window-load completes it changes to the Icon assigned. I want Icon there from beginning. Any help?

Edit:

I tried with .csproj --> Properties --> Application Tab --> Icon and set it to a .ico file. It works but I need to run my application by .exe file. It doesn't work in development environment(while running through visual studio). I need to set Start-Project option then. Is there any other way to solve this problem?

Tungstite answered 7/6, 2010 at 14:38 Comment(1)
I encountered a similar issue. When running my debug build on WIndows 7 32-bit the application icon was not displayed in the task bar (a default icon was used). This was not an issue on Windows 7 64-bit or with the release build on either Windows 7 32-bit or 64-bit. This was with .NET 4.5 and VS2013.Avelin
E
60

Check the properties of your main Window project.. You should be able to set an icon there.

Setting an icon on your project

Update: Is it such a problem that your icon does not show in debug mode? As long as it works when you deliver the program to your customer, its all alright, not?

On a side note: You could check some things though. Perhaps your icon is not included in your project, or it isnt copied when building to your Debug folder?

Update 2: You also need to set the Main Form's Icon for it to show in Debug. If you also set the icon for the main form, it will display in the Taskbar during Debug / Runtime.

Embolden answered 7/6, 2010 at 14:42 Comment(6)
thanks for the responce, but it works only when I run my application by .exe file. But when I run it in visual studio it doesn't work. I have updated my question for that.Tungstite
If it's really bothering you go to the Debug tab in the project settings and uncheck "Enable the Visual Studio hosting process". This will debug against the app directly instead of using the intermediate vshost.exe file.Lashio
Is this fixed in VS 2012+? I spent more time that I should have trying to diagnose my app's taskbar icon.Unravel
Could you please update your answer to include a note about setting the icon on the Main form. That was what I missed as well at RooiWillie (below)Subkingdom
..so what's the "Main Form" for a WPF app??Reitareiter
@Reitareiter In WPF that would be the main window and the Window.Icon propertyTenant
P
45

I had a similar issue and google led me to this article. I forgot one simple thing, and that was my Main Form's Icon. If you also set the icon for the main form, it will display in the Taskbar during Debug / Runtime.

Powered answered 30/4, 2013 at 6:48 Comment(1)
Brilliant. That's the simple, correct and precise answer!Metcalfe
L
34

For WPF applications, use the attribute

Icon="Images\Logo.ico"

for the Window element in XAML to have the window show the icon.

Liminal answered 6/8, 2014 at 14:14 Comment(3)
quick and clean. this should be the best answer.Sard
@Sard There are multiple points where you define icons for different purposes... the window icon (of the main window as shown in the task bar => the Icon="Images\Logo.ico" solution above) does not set the icon of the compiled executable (like the accepted solution of Arcturus does). Both are solutions for different things and none of these does replace the other. So there is no "best" if they have different behavior.Jonejonell
worked fine, I didn't notice that it was set before in my xaml so when I was setting the icon in the project it wouldn't show cause it was override by this linePfeiffer
P
5

I know this is old, but I found that I could get the icon to show in the taskbar in Debug mode if I went to the project's properties and checked the "Enable native code debugging" box on the "Debug" page

Piwowar answered 24/1, 2014 at 15:14 Comment(0)
D
0

That worked for me. In a VB application, go to Debug screen of Project options (of the UI project) and select Enable unmanaged code debugging. Not sure if there are any negative side effects, but it sure showed the icon during debug. Thanks.

Devondevona answered 1/2, 2014 at 22:38 Comment(1)
Looks like there is an unacceptable side affect: You can't edit code in debug mode. I'm guessing everyone knew that except me. Now I know.Devondevona
M
0

This is old but you can also change the shortcut icon in the setup projet, this is what worked for me (when viewing file system by right clicking the setup project).

Mass answered 9/7, 2015 at 4:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.