CanvasGeometry triangle = CanvasGeometry.CreatePolygon( new Vector2[] { new Vector2(0, 100), new Vector2(100, 100), new Vector2(50, 0)}); CanvasDrawingSession.DrawGeometry(triangle, Colors.Red);
CanvasGeometry rectangle = CanvasGeometry.CreateRectangle(new Rect(0, 0, 100, 100)); CanvasDrawingSession.DrawGeometry(rectangle, Colors.Blue);In the above code, we create a rectangle using the CanvasGeometry.CreateRectangle method and pass it to the DrawGeometry method of the CanvasDrawingSession object. We also specify the color of the rectangle as blue. Package Library: This method is a part of the Windows.UI.Xaml.Media namespace, which is a part of the Windows Runtime platform.