Picking the right resolution for RibbonWindow’s Icon
It has been reported that when using an icon file as RibbonWindow.Icon, the icon is rendered blurry due to bitmap scaling. The reason for this issue is the inherent behavior of WPF Image element to simply display the first decoded bitmap frame within an icon file instead of picking the best match in terms of resolution. This behavior isn’t really manifested unless you use the RibbonWindow. This is because when using a RibbonWindow WPF Image element is rendering the Application icon whereas for a regular WPF Window it is the OS that renders the icon and picks the right resolution. Attached is a workaround app that demonstrates how to manually decode the icon file and pick an image of the right resolution to be rendered as the Application Icon.
public override void OnApplyTemplate()
Image icon = GetTemplateChild("PART_Icon") as Image;
if (icon != null)
Size smallIconSize = SystemParameters2.Current.SmallIconSize;
BitmapDecoder decoder = BitmapDecoder.Create(new Uri(Icon.ToString()), BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
foreach (BitmapFrame frame in decoder.Frames)
if (frame.Width == smallIconSize.Width &&
frame.Height == smallIconSize.Height)
icon.Source = frame;
Please notice that the Application icon shows a red tint (which is the 16×16 icon), whereas the icon in the taskbar shows the yellow tint (which is the 32×32 icon).