27

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 image 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?

1 Answer 1

45

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

image.StretchDirection = StretchDirection.DownOnly;
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.