如何在WPF中强制图像保持长宽比?

时间:2022-08-27 10:50:42

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?

我在WPF窗口中有一个图像。当我调整窗口的大小时,图像也随之调整大小。当图像调整大小时,是否可以保持高宽比,这样当窗口太窄时就不会显得被压扁?如果是这样,如何?

1 个解决方案

#1


19  

Set the Image.Stretch Property to Uniform

设置图像。拉伸性质统一的

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

#1


19  

Set the Image.Stretch Property to Uniform

设置图像。拉伸性质统一的

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