Reputation: 558
I was totally tired of adding a Rectangle
to a path figure. Below was my tried code, but it does not results correctly as a Rectangle
:
PathGeometry geom = new PathGeometry();
Geometry g = new RectangleGeometry(myrectangel);
geom.AddGeometry(g);
PathFigureCollection collection = geom.Figures;
pathfigure = collection[0];
Is there any other way?
Upvotes: 4
Views: 3859
Reputation: 7429
You can combined geometries using a GeometryGroup. A GeometryGroup
creates a composite geometry from one or more Geometry
objects.
GeometryGroup gg = new GeometryGroup();
gg.Children.Add(new RectangleGeometry(new Rect(0, 0, 100, 100)));
gg.Children.Add(new RectangleGeometry(new Rect(100, 100, 100, 100)));
gg.Children.Add(new RectangleGeometry(new Rect(200, 200, 100, 100)));
System.Windows.Shapes.Path path = new System.Windows.Shapes.Path();
path.Data = gg;
path.Fill = Brushes.Blue;
Upvotes: 6