Exe logo in task manager is strected for win-ui 3 application.

mohan Raj 11 Reputation points
2023-02-20T10:28:22.9733333+00:00

Hi, I am currently working in an Win-Ui 3 Project, where i have added the icon to my application, but the thing is while running the application in task manager, the application icon is stretched out and not displaying properly in windows 11 . In Windows 10 icons are coming properly in task manger.

Steps to reproduce the bug

1.Create a winui-3 project.
2.In mainui.csproj add "Assets\Test.ico".
3.In mainwindow.xaml.cs class "AppWindow _appWindow;" , & In constructor "_appWindow.SetIcon(@"Assets\Test.ico");".
4.Run The application.
5.Open Task Manger and expand the application.

Expected behavior

Logo should display without strecthing in task manager.

NuGet package version

WinUI 3 - Windows App SDK 1.2.3: 1.2.230118.102

Windows version

Windows 11 (21H2): Build 22000

Additional context

Image resolution, I've added 256*256, I've changed the resolutions and tested not working as expected if i decrease the resolution of icon the image is fading in task bar.

Note: This issue us mainly coming in windows 11 OS, I've added the screen shot of windows 11 and windows 10 Windows10MSDN

Windows11MSdn

using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Graphics;

namespace TestHead
{
    
    /// A
    /// </su
     public sealed partial class MainWindow : Window
    {
        AppWindow appWindow;
        public MainWindow()
        {
            this.InitializeComponent();
            appWindow = this.GetAppWindow();
            appWindow.SetIcon(@"Assets\icon90.ico");
        }

        private void myButton_Click(object sender, RoutedEventArgs e)
        {
            myButton.Content = "Clicked";
        }
    }
    public static class WindowsExtensions
    {
        public static void Resize(this Window window, SizeInt32 size)
        {
            var appWindow = window.GetAppWindow();
            appWindow.Resize(size);
        }
        public static AppWindow GetAppWindow(this Window window)
        {
            var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(window);
            var myWndId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(hWnd);
            return AppWindow.GetFromWindowId(myWndId);
        }
    }
}

Windows development | Windows App SDK
{count} vote

1 answer

Sort by: Most helpful
  1. Castorix31 90,686 Reputation points
    2023-02-20T12:03:37.1433333+00:00

    Did you test with WM_SETICON and various formats as I posted on your issue on GitHub ?

    https://github.com/microsoft/microsoft-ui-xaml/issues/8134

    (and the forum here for WinUI3 is https://learn.microsoft.com/en-us/answers/tags/184/windows-app-sdk)


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.