Search code examples
asp.netmauimaui-blazormaui-windows

Icon Doesn't Appear for MAUI Blazor App on Windows if Taskbar Icons are Combined


I'm currently working on a MAUI Blazor app that needs to run on Windows and Android, and am running into an issue with the App Icon on Windows.

I can get it to populate through specifying the image in the Program file and the title in the MauiProgram.cs file, but when a user's settings are set to combine taskbar buttons, the app is just a blank space on the taskbar instead of the image and title combination.

Is it possible to keep this app from being combinable on the taskbar or force that image with that "combine buttons" setting still on and if so, how would I set this? If this isn't doable at the program level, is there a way to accomplish this on the device?

I've specified the icon sizes in the manifest for the app and they appear correctly if the "Combine Taskbar Buttons" option is set to "Never" or "When Taskbar Is Full" but this defaults to a blank space when collapsed.

This is the XML for the section of the Package.appxmanifest file:

  <Applications>
    <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="$targetentrypoint$">
      <uap:VisualElements
        DisplayName="Display Lookup"
        Description="Display Lookup"
        Square150x150Logo="Resources\Images\icon.png"
        Square44x44Logo="Resources\Images\icon.png"
        BackgroundColor="black">
        <uap:DefaultTile Square71x71Logo="Resources\Images\icon.png" Wide310x150Logo="Resources\Images\icon.png" Square310x310Logo="Resources\Images\icon.png"  ShortName="icon"/>
        <uap:LockScreen BadgeLogo="Resources\Images\BadgeLogo.png" Notification="badge"/>
      </uap:VisualElements>
    </Application>
  </Applications>


Solution

  • In Maui, if you want to change the app icon, just delete the previous icon in the Project-> Resources -> AppIcon, and add your new icon image to this folder, then set its Property -> Build Action to MauiIcon.So it is not necessary to change the icon related code in the Package.appxmanifest file.

    You can try the following steps to set the icon:

    1. Restore the code in Package.appxmanifest to the default code.
    2. Check if the Property of the icon file in Project-> Resources -> AppIcon is set to MauiIcon
    3. Check if the section in the .csproj file is set correctly:

    MauiIcon Include="Resources\AppIcon\icon.png" />

    For more settings about app icon, you can refer to Change the icon