How can I create a border with a specific aspect ratio?

Platform: .NET MAUI| Category: General

To create a border with a specific aspect ratio, wrap your content inside a grid and set the RowDefinition and ColumnDefinition sizes accordingly. Here’s an example:
XAML:

<Border Stroke="Black" Padding="0" WidthRequest="100" HeightRequest="50">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="1*"/>
                <RowDefinition Height="2*"/>
            </Grid.RowDefinitions>
        </Grid>
</Border>

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.