设置wpf应用程序的图标(VS 08)
在进一步讨论之前,我会提到我已经尝试过以下解决方案:
如何在 Visual Studio 2008 中设置应用程序的图标?
我正在尝试为我的应用程序设置图标。
AFAIK,我可能需要 3 张图片?
- 1 个图像是单击 .exe 时资源管理器中的实际图像(exe 的缩略图)
- 左上角的 1 个图像(很小)(16 x 16?不完全确定)
- 开始菜单停靠栏左侧的 1 个图像应用程序的大小(也许是 32x32?再次不确定)
所以没关系。
现在我选择了一个图标。在上述情况之一中我该如何使用它?
我尝试将其添加到资源中,但似乎没有任何反应。按照第一个 SO 解决方案,
“首先转到资源视图(从菜单:视图 --> 其他窗口 --> 资源视图)。然后在资源视图中导航资源(如果有)。如果已经存在图标类型的资源,由 Visual Studio 添加,然后打开并编辑它,否则右键单击并选择“添加资源”,然后添加一个新图标。”
资源视图是空的,我无法在此右键单击 。看法。
如果我右键单击解决方案>属性>资源>>我可以添加图标图像,但它没有显示在上面列出的任何位置。 (或我能看到的任何地方)
1) 如何设置 WPF 应用程序的应用程序图标?
Before going much further i'll mention I have tried solutions in following:
How do I set the icon for my application in visual studio 2008?
Set application icon from resources in VS 05
I am trying to set an icon for my application.
AFAIK, I need potentially 3 images?
- 1 image is the actual image in explorer when clicking on the .exe (thumbnail for the exe)
- 1 image (tiny) in the top left corner (16 x 16? Not entirely sure)
- 1 image in the start menu dock, to the left of the app (maybe 32x32? again not sure)
So thats fine.
Now I have selected an Icon. How do I use it in one of above situations?
I have tried adding it in resources, nothing seems to happen. Following that first SO solution,
"First go to Resource View (from menu: View --> Other Window --> Resource View). Then in Resource View navigate through resources, if any. If there is already a resource of Icon type, added by Visual Studio, then open and edit it. Otherwise right-click and select Add Resource, and then add a new icon."
The resource view is empty, and I cannot right click in this view.
If I right click on the solution > properties > resources > I can add the icon image, but it doesn't show in either of the locations listed above. (or anywhere that I can see)
1) How do I set the application icon for a WPF Application?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
假设您使用 VS Express 和 C#。
该图标在项目属性页面中设置。要打开它,请右键单击解决方案资源管理器中的项目名称。在打开的页面中,有一个“应用程序”选项卡,在此选项卡中您可以设置图标。
Assuming you use VS Express and C#.
The icon is set in the project properties page. To open it right click on the project name in the solution explorer. in the page that opens, there is an Application tab, in this tab you can set the icon.
@742 的答案效果很好,但正如注释中所述,从 VS 调试器运行时,通用图标仍然显示。
如果您希望即使在按 F5 时也有图标,您可以在主窗口中添加:
在其中指示图标的路径(图标可以是
*.png
、*.ico
。)(请注意,您仍然需要设置应用程序图标,否则它仍然是资源管理器中的默认图标)。
@742's answer works pretty well, but as outlined in the comments when running from the VS debugger the generic icon is still shown.
If you want to have your icon even when you're pressing F5, you can add in the Main Window:
where you indicate the path to your icon (the icon can be
*.png
,*.ico
.)(Note you will still need to set the Application Icon or it'll still be the default in Explorer).
注意:(将 file.ico 替换为您的实际图标文件名)
Icon=".\file.ico"
Note: (replace file.ico with your actual icon filename)
Icon=".\file.ico"
on the Window在收到带有消息的 XamlParseException 后:'使用给定的解决方案为'System.Windows.Baml2006.TypeConverterMarkupExtension'提供值,以编程方式设置图标对我有用。我就是这样做的:
Icon = new BitmapImage(new Uri("<icon_path>" , UriKind.Relative));
如果您在实施此解决方案时遇到任何困难,请告诉我,以便我提供帮助。
After getting a XamlParseException with message: 'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' with the given solutions, setting the icon programmatically worked for me. This is how I did it:
Icon = new BitmapImage(new Uri("<icon_path>", UriKind.Relative));
Please inform me if you have any difficulties implementing this solution so I can help.
你也可以尝试这个:
You can try this also: