简体   繁体   English

在WPF应用程序的Windows任务栏中显示错误大小的图标

[英]Wrong sized icon showing up in Windows taskbar for WPF app

I have a simple WPF app. 我有一个简单的WPF应用程序。 I have a nice multi-res icon with sizes all the way from 256x256 down to 16x16. 我有一个漂亮的多分辨率图标,大小从256x256到16x16。 All the usual stuff. 所有常见的东西。

My app looks awesome in Windows Explorer, the icon looks awesome, even at Extra Large view. 我的应用程序在Windows资源管理器中看起来很棒,即使在超大视图下,该图标看起来也很棒。 The icons scale nicely and I see the appropriate icon for the appropriate resolution. 图标很好地缩放,我看到适当分辨率的相应图标。

However, the 48x48 is always used for the pinned taskbar or pinned start menu and it looks awful. 但是,48x48始终用于固定任务栏或固定开始菜单,看起来很糟糕。

I can't find anything about this in the usual locations, but my gut says that someone must know something and I'm just missing something obvious. 我在通常的位置找不到任何相关的东西,但我的直觉说有人必须知道一些东西,我只是遗漏了一些明显的东西。

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 up. 而不是选择正确大小的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菜单,桌面和文件浏览器。

The icon size that is displayed in your taskbar is determined by a variety of factors; 任务栏中显示的图标大小由多种因素决定; 'MinWidth' value of HKEY_CURRENT_USER|Control Panel|Desktop|WindowMetrics, DPI settings, and taskbar settings. HKEY_CURRENT_USER的“MinWidth”值|控制面板|桌面| WindowMetrics,DPI设置和任务栏设置。

48x48 is chosen because the default 'MinWidth' setting is (i believe) 53, and the 48x48 is the largest resolution in your icon that fits within that setting. 选择48x48是因为默认的“MinWidth”设置是(我相信)53,而48x48是图标中适合该设置的最大分辨率。

if you are unhappy with the way the 48x48 icon looks, it may just need re-designed. 如果您对48x48图标的外观不满意,可能只需要重新设计。 Be sure it is using the correct number of colors, etc. How do the small icons look? 确保使用正确数量的颜色等。小图标看起来如何? As bad or worse than the 48x48? 比48x48差还是差? if so, then perhaps the icon is too complex to look good at such a small resolution. 如果是这样,那么也许图标太复杂而不能在如此小的分辨率下看起来很好。

I know of no way to force windows to select a different icon size for the taskbar. 我知道无法强制窗口为任务栏选择不同的图标大小。

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

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