简体   繁体   English

WPF应用程序中的任务栏丑陋图标

[英]Taskbar ugly icon in WPF application

The icon in the taskbar is looking very ugly in my WPF application. 在我的WPF应用程序中,任务栏中的图标看起来非常难看。

The designer sent me some PNGs like: 设计师给我发了一些PNG,比如:

32x32, 64x64, 96x96, 128x128, 192x192, 256x256, 512x512. 32x32,64x64,96x96,128x128,192x192,256x256,512x512。

What do I have to do to get the goodloking taskbar icon? 我需要做什么才能获得goodloking任务栏图标?

Thank you! 谢谢!

Make an .ico file containing multiple sizes. 制作包含多种尺寸的.ico文件。 At a minimum, you should have the following sizes: 16x16, 32x32, 48x48, and 256x256 according to the Windows icon visual guidelines . 根据Windows图标可视化指南 ,您至少应具有以下大小:16x16,32x32,48x48和256x256。 Having a single .ico file will help Windows pick the best size and scale it appropriately depending on the situation (application icon, large taskbar, small taskbar, etc.) 拥有单个.ico文件将帮助Windows选择最佳大小并根据具体情况(应用程序图标,大型任务栏,小任务栏等)进行适当扩展。

If you aren't a designer, then it's also better to let your designer make the 16x16 image, since it's possible the larger images you have have too much detail and do not scale down very well. 如果你不是设计师,那么让你的设计师制作16x16图像也会更好,因为你可能有更大的图像有太多的细节而且不能很好地缩小。 If the larger images are very detailed, then the designer could make the smaller images simpler so that the icon shows better. 如果较大的图像非常详细,那么设计人员可以使较小的图像更简单,以便图标更好。 The visual guidelines linked above have more tips about this. 上面链接的视觉指南有更多关于此的提示。

I had the same problem, it was not working even with a multi-sized .ico file. 我遇到了同样的问题,即使使用多尺寸的.ico文件也无法正常工作。 Setting the icon directly in the Window resulted in a pixelated icon. 直接在窗口中设置图标会产生像素化图标。

I managed to fix it with this code-behind for the application window: 我设法用应用程序窗口的代码隐藏修复它:

private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        Uri iconUri = new Uri("pack://application:,,,/Images/myicon.ico", UriKind.RelativeOrAbsolute); //make sure your path is correct, and the icon set as Resource
        this.Icon = BitmapFrame.Create(iconUri, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad);

        //etc.
    }

Icon file is multi-sized, this worked for me in WPF - Windows 10. 图标文件是多尺寸的,这在WPF - Windows 10中对我有用。

You can convert your .png icon into a multi-sized .ico file here http://icoconvert.com/ 您可以将.png图标转换为多尺寸的.ico文件http://icoconvert.com/

Taskbar icons seem to get blurry as soon as a 48x48 pixels version is included in the .ico file. 只要.ico文件中包含48x48像素版本,任务栏图标就会变得模糊。 Instead of picking the correctly sized 32x32 pixels version, for some reason Windows apparently picks the 48x48 one and scales it down. 而不是选择正确大小的32x32像素版本,出于某种原因,Windows显然选择48x48版本并将其缩小。

The solution for me is to use two separate icon files: 对我来说,解决方案是使用两个单独的图标文件:

  • One .ico containing 24x24 and 32x32 versions of the icon, which will, when set as a Window's icon using the Icon property in XAML or Hannish's approach, be used for the titlebar and taskbar respectively - without unwanted scaling. 一个.ico包含24x24和32x32版本的图标,当使用XAML或Hannish方法中的Icon属性设置为Window的图标时,将分别用于标题栏和任务栏 - 无需不必要的缩放。
  • A second icon file containing - depending on which sources are right - a range of sizes between 16x16 and 256x256 pixels. 第二个图标文件,包含 - 取决于哪些源是正确的 - 一系列大小介于16x16和256x256像素之间。 Setting this one as the application icon in the project properties will make the icon look good in all the other places like the desktop and the file explorer on different view settings. 将此项目设置为项目属性中的应用程序图标将使图标在所有其他位置(如桌面和文件浏览器)上在不同的视图设置上看起来很好。

Testing on Windows 10, this seems to cover the following display cases: taskbar, window titlebar, Alt-TAB menu, Desktop and file explorer. 在Windows 10上进行测试,这似乎涵盖了以下显示案例:任务栏,窗口标题栏,Alt-TAB菜单,桌面和文件浏览器。

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

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