Taskbar ugly icon in WPF application

前端 未结 3 693
醉梦人生
醉梦人生 2021-02-14 15:41

The icon in the taskbar is looking very ugly in my WPF application.

The designer sent me some PNGs like:

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

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-14 16:08

    I had the same problem, it was not working even with a multi-sized .ico file. 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.

    You can convert your .png icon into a multi-sized .ico file here http://icoconvert.com/

提交回复
热议问题