简体   繁体   English

将UniformToFill与图像一起使用时,如何在C#或XAML中控制剪裁

[英]How do I control clipping in C# or XAML when using UniformToFill with an image

I have an image control in a resizable window with its stretch property set to UniformToFill . 我在一个可调整大小的窗口中有一个图像控件,其stretch属性设置为UniformToFill

<Image Name="some_image" Stretch="UniformToFill" Margin="0,0,0,0" />

The clipping window is pegged to the top left of the image; 剪切窗口固定在图像的左上角; resizing chops off the right and bottom of the image. 调整图像右侧和底部的切块大小。

I want the image to be clipped equally on all sides. 我希望图像在所有方面均匀剪裁。 Am I being dense and overlooking an obvious solution? 我是否密集并且忽略了明显的解决方案?

How do I control how the image gets clipped? 如何控制图像被剪裁的方式?

(Unrelated: This is my first post to stackoverflow. I just wanted to start off saying, thanks, this site has been amazing resource for me) (不相关:这是我在stackoverflow上的第一篇文章。我只是想开始说,谢谢,这个网站对我来说是一个很棒的资源)

The HorizontalAlignment and VerticalAlignment property determine this behavior with an image control. Horizo​​ntalAlignment和VerticalAlignment属性使用图像控件确定此行为。

 <Image Name="some_image" Stretch="UniformToFill" Margin="0,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" />

Guess i was being dense! 猜猜我是密集的!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM