tags:

views:

684

answers:

2

If I have a multi-resolution icon file (.ico), how can I insure that WPF picks the right sized one? Does setting the width and height of the Image force it, or does WPF simply resize the first icon in the ico file?

This is what I'm using currently (it works, but I'd like to avoid the resizing if that's what's happening).

<MenuItem.Icon>
    <Image Source="MyIcons.ico" Width="16" Height="16"  />
</MenuItem.Icon>

I'd like to declare this in Xaml if possible without having to code for it.

A: 

If the reason you're asking is that the icon looks blurry to you, check out this very good article on the topic that I used to solve that problem: http://blogs.msdn.com/dwayneneed/archive/2007/10/05/blurry-bitmaps.aspx

You will have to use a custom control that not only sizes the icon exactly, but ensures that it coincides exactly with the pixel grid. Only then will you avoid interpolation and therefore blurriness.

Trying to find some info on your query about image size selection in icons...will post back if I find any...

PeterAllenWebb
Well, it's only blurry in the sense that the image was rescaled. I'm just really curious on how to pick the right image from a multi-image, multi-resolution .ico file in Xaml.
SergioL
+1  A: 

It doesn't appear to be possible using Xaml only.

SergioL
Thats really unfortunately but thanks for the brutal honesty, it's better than no answer at all.
jpierson