所有应用程序窗口的 WPF 图标
可以设置一个图标,以便在当前应用程序的每个窗口上使用它。这样我就设置了一次(不是手动在每个窗口上设置)..?
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)..?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
关于该主题的一个很好的参考是这里 MSDN 。说明您有一个应用程序图标(桌面图标),每个窗口都有一个图标。
WPF 窗口始终显示一个图标。如果未通过设置 Icon 来提供图标,WPF 将根据以下规则选择要显示的图标:
使用程序集图标(如果指定)。
如果未指定程序集图标,则使用默认的 Microsoft Windows 图标。
社区内容参考:
“小提示:如果您设置应用程序图标并希望在窗口上看到它 - 如果从 VS 调试运行,则它不会显示。在外部运行或不附加 (ctrl + f5) 图标将按预期显示”。
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."
在“资源”部分的“应用程序”选项卡上的项目属性中设置图标。该图标将成为应用程序中所有窗口的默认图标。
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.
在 VS2010 下,打开主应用程序可执行文件的“属性”,然后打开“应用程序”选项卡。在资源部分的“图标和清单”下设置图标。
要在 VS2010 下调试时看到该图标,您需要打开“调试”选项卡并取消选中“启用 Visual Studio 托管进程”选项,否则您将只能在大多数窗口上看到默认图标。
我假设图标加载代码被托管进程混淆,并且正在“someapplication.vshost.exe”而不是“someapplication.exe”中查找图标。
这看起来像是在 VS2013 中修复的。
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.
“启用 Visual Studio 托管进程”导致图标不起作用的原因是它是使用 vshost.exe 启动的,因此无法正确读取清单。
如果清单中有其他内容,例如需要加载清单的 regfree ocx 控件等,情况也是如此。
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: