I am self-training myself in WPF. I am using a Canvas
to have two polygons grouped together:
var grp = new Canvas();
var polygon = new new Polygon();
polygon.Points.Add(new Point(-15, -20));
polygon.Points.Add(new Point(0, 20));
polygon.Points.Add(new Point(15, -20));
polygon.StrokeThickness = 1;
polygon.Stroke = Brushes.Violet;
polygon.Fill = Brushes.Yellow;
var rotationCenter = centroid(polygon);
var centerPoint = new Ellipse();
Canvas.SetLeft(centerPoint, rotationCenter.X -1 );
Canvas.SetTop(centerPoint, rotationCenter.Y-1);
centerPoint.Fill = Brushes.Green;
centerPoint.Height = 3;
centerPoint.Width = 3;
grp.Children.Add(shipPolygon);
grp.Children.Add(centerPoint);
Then, I move, rotate and play with my grouped polygons using the grp Canvas
.
Because I don't want to use my Canvas
for anything else than grouping polygons each other, I wonder if it exists something lighter than a Canvas
to do this.
I searched for something equivalent of Model3DGroup
in WPF3D to group UIElements in WPF2D, but without success.
Is Canvas
the lightest container to group UIElements ?