如何反转在Silverlight / WPF裁剪几何? [英] How to invert clipping geometry in Silverlight/WPF?
问题描述
的<一个href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.clip.aspx"><$c$c>UIElement.Clip$c$c>房地产需要一个<一个href="http://msdn.microsoft.com/en-us/library/system.windows.media.geometry.aspx"><$c$c>Geometry$c$c>对象,并用它来剪裁掉的UIElement
的外面。我愿做几何逆和打眼到元素代替。
The UIElement.Clip
property takes a Geometry
object and uses it to clip away the outside of the UIElement
. I would like to do the geometric inverse and punch a hole into the element instead.
任何人都知道如何做到这一点?
Anyone know how to do this?
我想创建剪辑的几何形状会工作的一个倒置的版本,但我不能找到一个方法来做到这一点。
I imagine creating an inverted version of the clip geometry would work, but I can't find a way to do this.
修改看来,WPF有 几何。结合
的,可用于对减去另一个几何,虽然这不是在Silverlight可用。如果是这样,我可以从元素的边框的矩形减去剪辑的几何形状,并用它来代替夹
EDIT It seems that WPF has Geometry.Combine
which can be used to subtract one geometry from another, though this isn't available in Silverlight. If it were, I could subtract the clip geometry from the rectangle of the element's bounding rectangle, and use that to clip instead.
推荐答案
在Silverlight的一种方法是使用 GeometryGroup
,其中包括该集团一个非常大的矩形开始在一个遥远的消极立场。
One approach in Silverlight is to use a GeometryGroup
and include in the group a very large rectangle starting at a distant negative position.
例如下面的蓝色方块的小方孔: -
For example the following blue square has smaller square hole:-
<Rectangle Fill="Blue" HorizontalAlignment="Center" VerticalAlignment="Center" Height="200" Width="200">
<Rectangle.Clip>
<GeometryGroup>
<RectangleGeometry Rect="-2048 -2048 4096 4096" />
<RectangleGeometry Rect="100 100 50 50" />
</GeometryGroup>
</Rectangle.Clip>
</Rectangle>
这篇关于如何反转在Silverlight / WPF裁剪几何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!