开发者

Shrinking Images rather than Stretching

开发者 https://www.devze.com 2023-03-04 18:56 出处:网络
I am having a little trouble in WPF - I am fully aware of the image stretch function and how to use it, and have that working fine.What I am trying to do however, is only apply the stretch if the imag

I am having a little trouble in WPF - I am fully aware of the image stretch function and how to use it, and have that working fine. What I am trying to do however, is only apply the stretch if the image is too large (essentially to make it a shrink), and retain the original size if the i开发者_运维问答mage would fit into the view. The stretch method currently performs the shrinking perfectly, but will expand smaller images to fill the view which is not what I am after.

Is there a simple way of doing this?


you have to use the StretchDirection property in conjunction with the Stretch Property:

image.StretchDirection = StretchDirection.DownOnly;
0

精彩评论

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

关注公众号