I have a complex StreamGeometry and I want to trim it. Unfortunately, it seems that StreamGeometry does not support the compiler.
Here is a test.
Xaml:
<Path x:Name="path" Stroke="Red"/>
the 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); }
Uncommenting the first line (to display rect ) or the second line (to display stream ) gives the same visual result:


An uncommenting third line (to show clip ) or a fourth line (to show the intersection of clip and rect ) will produce:


While uncommenting the last line (to display the intersection of clip and geometry ) creates a 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;