简体   繁体   English

在资源管理器中设置应用程序图标?

[英]Setting application icon in Explorer?

I am trying to set a file icon for a program I am creating.我正在尝试为我正在创建的程序设置文件图标。 I can get the icon to show on the taskBar when I am running the program.当我运行程序时,我可以让图标显示在taskBar上。 But I can't get it to show in a file explorer.但我无法让它显示在文件浏览器中。

Here is an example screenshot from Explorer:这是资源管理器的示例屏幕截图:

例子

I have embedded the icon into the project, and set it as the windows icon using我已将图标嵌入到项目中,并使用

Icon="Sample.ico"

Thanks谢谢

Have you selected the icon for your application?您是否为您的应用程序选择了图标? (project properties > tab application > symbol and manifest > symbol) (项目属性 > 选项卡应用程序 > 符号和清单 > 符号)

The following example shows how to set a window icon.以下示例显示如何设置窗口图标。

By using XAML,通过使用 XAML,

<Window
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="SDKSample.MainWindow"
    Icon="WPFIcon1.ico">
</Window>

By using c# code,通过使用 c# 代码,

Uri iconUri = new Uri("pack://application:,,,/WPFIcon2.ico", UriKind.RelativeOrAbsolute);
this.Icon = BitmapFrame.Create(iconUri);

By using VB,通过使用VB,

Dim iconUri As New Uri("pack://application:,,,/WPFIcon2.ico", UriKind.RelativeOrAbsolute)
Me.Icon = BitmapFrame.Create(iconUri)

For more info, refer this .有关更多信息, 请参阅此

Make sure your .ico file contains the right selection of sizes so that the appropriate one displays in explorer.确保您的 .ico 文件包含正确的尺寸选择,以便在资源管理器中显示合适的尺寸。

For Windows you'll want: 256 x 256 pixels, 48 x 48 pixels, 32 x 32 pixels and 16 x 16 pixels.对于 Windows,您需要:256 x 256 像素、48 x 48 像素、32 x 32 像素和 16 x 16 像素。

All 32bit (24bit colour, 8bit transparency).全部为 32 位(24 位颜色,8 位透明度)。

Kindly use the .ico file don't use JPEG or any other formats请使用 .ico 文件,不要使用 JPEG 或任何其他格式

<Window Icon="youricon.ico"></Window>

http://msdn.microsoft.com/en-us/library/system.windows.window.icon.aspx http://msdn.microsoft.com/en-us/library/system.windows.window.icon.aspx

you have to include Icon="Path to icon" in window definition of the main window.您必须在主窗口的窗口定义中包含Icon="Path to icon"

<Window 
//rest of code
Icon="Path to icon"></Window>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM