开发者

WPF: Inserting an Image element which should default to its own size

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 开发者_Go百科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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜