how to display grid border in grid in maui?

mc 5,426 Reputation points
2023-06-23T09:02:51.7366667+00:00

the vertical row border and horizontal column border?

how to display it?

Developer technologies .NET .NET MAUI
{count} votes

Accepted answer
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 36,436 Reputation points Microsoft External Staff
    2023-06-27T01:32:55.8066667+00:00

    Hello,

    There is not a Border property in Grid, you could try to set the space between rows and columns so that it looks like border.

    (Setting margin will make a border around the Grid)

    <ContentPage BackgroundColor="Black"...>
        
        <Grid Margin="2" BackgroundColor="Black" RowSpacing="2"
              ColumnSpacing="2">
            <Grid.RowDefinitions>
                <RowDefinition Height="2*" />
                <RowDefinition Height="*" />
                <RowDefinition Height="100" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
    
           <BoxView Grid.Row="0" Grid.Column="0"
                     Color="LightSkyBlue" />
            <BoxView Grid.Row="0" Grid.Column="1"
                     Color="LightSkyBlue" />
            <BoxView Grid.Row="1" Grid.Column="0"
                     Color="LightSkyBlue" />
            <BoxView Grid.Row="1" Grid.Column="1"
                     Color="LightSkyBlue" />
            <BoxView Grid.Row="2" Grid.Column="0"
                     Color="LightSkyBlue" />
            <BoxView Grid.Row="2" Grid.Column="1"
                     Color="LightSkyBlue" />
        </Grid>
    </ContentPage>
    

    Best Regards,

    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.