tags:

views:

52

answers:

1

For some reason when I use <Image ...> in WPF, the image is shown smaller than its actual size. There is plenty of space for the image, it's just that it takes up all the space it can by default:

<Image Source="data/images/my-image.png" />

I tried setting Stretch="None" but when I do that, the image is displayed smaller than its actual size! So what's going on here?

A: 

How is the Image container defined? The Image control you have defined (which will apply the default Stretch=Uniform) should fill all available parent space BUT retain its aspect ratio. Because of this you will typically end up with empty space either on the top and bottom or sides. Experimenting with the other Stretch options will show you how they work.

If the parent space is smaller than the actual image, then it will adjust down. If the parent space is larger than the actual image, then the image will be stretched to fill the available space causing pixelation as necessary.

Joel Cochran