I have 3 multi-resolution icon files (.ico). Each one contains sizes 16x16, 24x24, 32x32, 48x48, 64x64 and 96x96
The icon is being dynamically picked by using binding.
<Image Source="{Binding ImageSource}" />
and following is the code where imageSource is being set:
_imageSource = Imaging.CreateBitmapSourceFromHIcon(icon.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
the column in which the image is being placed has Width="Auto"
I know that having a single .ico file helps Windows pick the best size. However, I am facing a problem that the icon size is different depending on which icon is being picked
e.g.: For one image 32x32 size is being picked and for the other 48x48 size is being picked.
Why? Is there a problem with the code or is it with the icons?
Please note that width is not being set anywhere in the code.
Another thing that is confusing me is that all examples I have seen for CreateBitmapSourceFromHIcon
are passing Int32Rect.Empty as the second argument (i.e.: sourceRect). However, I haven't found some good explanation on how it affects the image size. Some explanation regarding this will be highly appreciated