I have complex StreamGeometry
and I want to clip it. Unfortunately, it looks like StreamGeometry
doesn't supports combine.
Here is a test.
Xaml:
<Path x:Name="path" Stroke="Red"/>
Code:
var clip = new RectangleGeometry(new Rect(50, 50, 10, 10));
var rect = new RectangleGeometry(new Rect(0, 0, 100, 100));
var stream = new StreamGeometry();
using (var geometry = stream.Open())
{
geometry.BeginFigure(new Point(0, 0), false, true);
geometry.LineTo(new Point(0, 100), true, false);
geometry.LineTo(new Point(100, 100), true, false);
geometry.LineTo(new Point(100, 0), true, false);
}
//path.Data = rect;
//path.Data = stream;
//path.Data = clip;
//path.Data = Geometry.Combine(rect, clip, GeometryCombineMode.Intersect, null);
//path.Data = Geometry.Combine(stream, clip, GeometryCombineMode.Intersect, null);
Uncommenting first line (to show rect
) or second line (to show stream
) produces same visual result:
Uncommenting third line (to show clip
) or fourth line (to show intersection of clip
and rect
) will produce:
While uncommenting last line (to show intersection of clip
and geometry
) produce blank screen.
My question is: how to combine (clip) StreamGeometry?
I know there is UIElement.Clip
, but:
// blank screen
path.Data = stream;
path.Clip = clip;
// blank screen as well
path.Data = stream;
path.Clip = clip;