Search code examples
c#xamarinpathgeometrymaui

Convert Xamarin.Forms.Shapes.Path to MAUI


I want to draw a circle within a grid. My old Xamarin code looked like this:

public int DrawCircle(Brush colour, int strokeThickness, int x, int y, int width, int height, Grid cv)
{
    Path c1 = new Path();
    c1.Stroke = colour;
    c1.Fill = transparentBrush;
    c1.StrokeThickness = strokeThickness;
    EllipseGeometry myEllipseGeometry = new EllipseGeometry();
    myEllipseGeometry.Center = new Point(x, y);
    myEllipseGeometry.RadiusX = height;
    myEllipseGeometry.RadiusY = width;
    c1.Data = myEllipseGeometry;
    cv.Children.Add(c1);

    return cv.Children.Count - 1;
}

I can't seem to figure out the MAUI way of doing this.

Thanks in advance


Solution

  • Convert Xamarin.Forms.Shapes.Path to MAUI

    The Xamarin.Forms.Shapes.Path in xamarin is same as the Microsoft.Maui.Controls.Shapes.Path in maui.

    So you can add the following name space and then use your code directly.

    using Path = Microsoft.Maui.Controls.Shapes.Path;