1

If large images are displayed in a size smaller than the original, then begin to show artifacts "pixelation":

https://habrastorage.org/files/8a6/198/506/8a61985069cb4d0097540bf0d07f4a68.png

But this can be solved by specifying the attribute of the object in XAML, scaling algorithm with higher quality:

<Image Height="50" Width="50" 
     Source="Resources/logo.png" 
     RenderOptions.BitmapScalingMode="HighQuality" /><!-- Scaling Mode -->

Then, the image looks fine:

https://habrastorage.org/files/819/863/48f/81986348f9ab454a9d6b676d88321d0a.png

Question. How to change the scaling algorithm that is applied to the icon in the window? Icon set through XAML (the last line):

<Window x:Class="MyApp.AboutWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/present"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:res="clr-namespace:MyApp.Properties"
Title="{x:Static res:Resources.AboutWindowTitle}" 
Height="450" Width="300" 
ResizeMode="NoResize" 
WindowStartupLocation="CenterOwner"
Icon="Resources/info.png"><!-- Icon -->

Icon in the title bar looks like this:

_https://habrastorage.org/files/946/bb7/67b/946bb767b66042aba985a8e55a21b078.png (Sorry, I do not have enough reputation to post third link)

Attribute RenderOptions.BitmapScalingMode = "HighQuality" applied to the window, gives nothing.

Mikhail
  • 2,612
  • 3
  • 22
  • 37

1 Answers1

0

Unlike the elements in client area, those in title bar are not under direct control of a WPF application. A png file set to a Window's Icon property will be converted to the icon image in title bar (and that in task bar) but as you see, the conversion seems to be quite limited.

So as far as I know, unfortunately, the only practical solution to set nicely shown icon in title bar is to create or find an icon file (.ico) which has multiple images inside and use it instead of merely a png file.

emoacht
  • 2,764
  • 1
  • 13
  • 24