[UWP]剪切倒置的矩形 [英] [UWP]Clip an inverted rectangle
问题描述
我知道可以剪切一个矩形,将一个RectangleGeometry分配给Clip属性,但这样可以保留矩形的内部部分并剪切外部部分。是否有可能做相反的事情?我想在视觉
元素中制作矩形孔。
Alvaro Rivoir
I know it is possible to clip a rectangle assigning a RectangleGeometry to the Clip property, but that keeps the internal part of the rectangle and clips the external part. Is it possible to do the opposite? I want to make rectangular hole in a visual element.
Alvaro Rivoir
推荐答案
Hello Alvaro Rivoir,
Hello Alvaro Rivoir,
实际上我建议使用路径而不是矩形。
Actually I would recommend using path instead of rectangle.
类似下面的代码:
<Path Fill="Blue" Height="220" Width="270">
<Path.Data>
<GeometryGroup>
<RectangleGeometry Rect="40,40,180,150"/>
<RectangleGeometry Rect="0,0 300,300"/>
</GeometryGroup>
</Path.Data>
</Path>
结果将是:
有关更多信息,请参阅有关路径的官方文档:https://docs.microsoft。 com / en-us / uwp / api / Windows.UI.Xaml.Shapes.Path
For some more you can refer to the official doc about path:https://docs.microsoft.com/en-us/uwp/api/Windows.UI.Xaml.Shapes.Path
它包含一个存在的样本。
It contains an exist sample.
祝你好运,
Barry
这篇关于[UWP]剪切倒置的矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!