首页 > 解决方案 > Winforms app packaged for MS Store displays incorrect icon on Taskbar

问题描述

I packaged my Winforms app in Visual Studio using the "Windows Application Packaging Project" (WAPP ---formerly the "Desktop Bridge"). When I test the Store install created by WAPP (.appxbundle file) the app installs and launches correctly but the app icon displayed in the Windows Taskbar is not correct (it displays a very small version of my app's icon with a ?blue-square? background).

The icon file I use for my app provides the following image sizes (with transparent background): 16x16, 24x24, 32x32, 48x48 and 256x256.

The main form for the app (which is the only form displayed at launch) has the following properties set in the form's designer:

ShowInTaskbar=True
ShowIcon=True
Icon=*my icon file*

My app's properties page has 'Application>Icon' set to the same icon file described above.

Also in troubleshooting this issue I tried adding the icon file to my app's 'Resoures>Icons' and added the following code to the main form's Form_Load event to re-apply the file at run-time:

Me.Icon = My.Resources.MyIcon7

With this run-time code the Store app continues to display the small/incorrect icon image with a blue background in the Taskbar.

The icon displayed in the Windows Start menu is the correct (larger) icon with correct transparent background.

Also if I launch the 'non-Store' build of my app using the .exe (created here 'bin\Release\myapp.exe' when building the app in Visual Studio) the correct icon displays in the taskbar.

Many thanks!

标签: winformsiconswindows-store-appsdesktop-bridge

解决方案


OK I figured this out! Here is the solution... The icons used by the MS Store installed version of the app must be provided in the "Windows Application Packaging Project" (formerly the "Desktop Bridge").

To access and/or provide these icons:

  1. In Visual Studio go to the Solution Explorer and expand the node for the "Windows Application Packaging Project" that you added to your solution.
  2. Locate and double click on Package.appxmanifest in the expanded node. This opens the manifest GUI
  3. Click on the Visual Assets tab in the manifest GUI
  4. Cycle through the image-categories on the left-hand side and make sure you are happy with all the images. Note: The images for the TaskBar are under the App Icon category

Additionally the blue background that was appearing on my Icon in the TaskBar is apparently the default behavior of Windows Themes. Windows examines the icons that you provide for your app and determines if the icon will contrast well with the TaskBar color of the current theme. If Windows thinks your icon will NOT look good with the current Theme it creates & displays a "Plated" version of your icon instead of the regular "unplated" version. When an icon is plated the icon is shrunken slightly and placed on a square blue background (which in my opinion looks ugly and out of place). To override this default behavior and provide your own theme-specific icon for the light Windows theme add a new icon file to the Assets folder (in Solution Explorer) with the text "lightunplated" in the file name. For example my Assets folder contained the following icon file: Square44x44Logo.targetsize-24_altform-unplated.png which was being used as the Taskbar icon when Theme was set to Dark. I created a new icon file named: Square44x44Logo.targetsize-24_altform-lightunplated.png and added it to the Assets folder by right-clicking on the folder and selecting Add>Existing Item. After being added, the new icon is used by windows when Theme is set to light and is not "Plated" by windows.


推荐阅读