Search code examples
maui

MAUI: how to use Border StrokeShape property to draw a perfect circle?


My last attempt was this:

<Border Stroke="#649B33"
        StrokeThickness="1"
        StrokeShape="Ellipse 30, 30"
        Padding="8"
        Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"
        HorizontalOptions="Center">
        <Label Text="1" FontAttributes="Bold" />
</Border>

Documentation is very very poor regarding StrokeShape property, so I am trying to guess the correct way, but I have actually spent too much time and nothing works.

Can you show me how to use StrokeShape property to achieve what I need?


Solution

  • this works for me

    <Border Stroke="#649B33"
            StrokeThickness="10"
            StrokeShape="Ellipse 40, 40"
            Padding="8"
            HorizontalOptions="Center">
        <Label HorizontalTextAlignment="Center"
               VerticalTextAlignment="Center" 
               WidthRequest="40" HeightRequest="40"
               Text="1" FontAttributes="Bold" />
    </Border>
    

    I think the key is setting the same width and height values for the label so that it is square