问题描述
我正在为Windows Phone 7使用C#,Silverlight,Visual Studio.
I am using C#, Silverlight, Visual Studio for Windows Phone 7.
是否可以提供UIElement
多个Geometry剪辑?等同于:
Is there a way to give a UIElement
multiple Geometry clips? Something equivalent to:
Path myPath = new Path();
myPath.Data = myRectangle; // say of size 100x100
myPath.Clip = myClipRect; // smaller rectangle, say of size 20x20, located at (0,0)
myPath.Clip = myClipEllipse; // circle of radius 30, centered on myRectangle
现在,myClipEllipse将覆盖myPath.Clip中的myClipRect,因此仅显示myClipEllipse.我正在寻找一个可以正确绘制这两个剪辑的myRectangle的结果(即未反转).
Right now, myClipEllipse will override myClipRect in myPath.Clip, so only myClipEllipse will be displayed. I'm looking for a result that draws myRectangle with both of these clips correctly (ie, not inverted).
推荐答案
我最终使用GeometryGroup
类(此处的文档).只需将所有几何图形作为GeometryGroup
的子级,然后将此GeometryGroup
提供给Clip.
I ended up solving this using a GeometryGroup
class (docs here). Just put all the geometries as children of the GeometryGroup
, and give this GeometryGroup
to the Clip.
这篇关于UIElement上的多个几何剪辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!