How to show empty gird rows?

Takeshi 41 Reputation points
2023-04-07T19:54:01.89+00:00

Hi all, I have one little problem. I created a Grid with a few rows ... BUT problem is the empty rows doesnt appear ... only when I but for example label in some row ... it appear ... why?

<Grid Width="500">   
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition />
        <RowDefinition />
        <RowDefinition />
    </Grid>

Thank you.

Developer technologies XAML
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2023-04-10T08:57:09.6233333+00:00

    Hi @Takeshi ,Welcome to Microsoft Q&A, you could try the following code to get what you wanted.

    <Grid Width="500">
        <Grid.Resources>
            <Style TargetType="Border">
                <Setter Property="BorderThickness" Value="1,1,1,1" />
                <Setter Property="BorderBrush" Value="Black" />
            </Style>
        </Grid.Resources>
    
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
    
        <Border Grid.Row="0" />
        <Border Grid.Row="1" />
        <Border Grid.Row="2" />
        <Border Grid.Row="3" />
    </Grid>
    

    You can check this documentation: XAML object elements, you need Completing the tag with a forward slash and closing angle bracket in succession (/>).

    enter image description here

    Best Regards,

    Jiale


    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.

    0 comments No comments

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.