DaveDev
DaveDev

Reputation: 42175

How can I force an image to maintain aspect ratio in WPF?

I have an image in a WPF window. When I resize the window the image resizes with it. Is it possible to preserve the aspect ratio when the image is resizing, so it doesn't look squashed if the window is too narrow? If so, how?

Upvotes: 18

Views: 17475

Answers (1)

Fede
Fede

Reputation: 44038

Set the Image.Stretch Property to Uniform

<Image Stretch="Uniform" ....etc />

Upvotes: 32

Related Questions