Usually I have to set 2 different icons. One in the project's settings tab, and one to the Icon
property of main window. Is there a way to define single icon for the whole application (all windows and exe)?
Update: to be more concret开发者_JS百科e. I have app that is 100kb in size. I want to embed icon that is 300kb in size and want my app to be 400kb instead of 700
You need to set the icon in you project's properties:
For taskbar you need to change your main window's Icon:
When you set your exe icon, WPF will use that for all Windows you create. However, it doesn't do it in debug mode - that's because the "entry point" for your process is the .vshost.exe, not your exe. But if you use Ctrl+F5 (run without debugging), you should find all Windows get the exe icon. You shouldn't have to set it on each Window.
To make it work properly in debug mode, I generally set up a Style which I apply to each window, which sets the application icon.
精彩评论