问题
I am using C#, Silverlight, Visual Studio for Windows Phone 7.
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
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).
回答1:
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.
来源:https://stackoverflow.com/questions/12896493/multiple-geometry-clips-on-a-uielement