Skip to content

Grid isn't calculating row height correctly in some cases when RowSpan is used #7299

Open
@zlatanov

Description

@zlatanov
  • .NET Core Version: All
  • Windows version: 11
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes

The following XAML:

<Grid Width="400" Background="Black">
    <Grid.ColumnDefinitions>
        <ColumnDefinition />
        <ColumnDefinition Width="100" />
        <ColumnDefinition Width="100" />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <Border Grid.ColumnSpan="2"
            Height="100"
            Background="Green" />

    <Border Grid.RowSpan="2"
            Grid.Column="2"
            Height="200"
            Background="Aquamarine" />

    <Border Grid.Row="1"
            Height="100"
            Background="Orange" />

    <Border Grid.Row="1"
            Grid.Column="1"
            Height="100"
            Background="Red" />
</Grid>

should render two rows, each with height of 100 because each element has a height of 100, with exception of the one that spans 2 rows, which has a height of 200.

However, the result is the following:
image

The second row is exactly 1.5 times the height it should be.

Expected behavior:
image

If we insert the following:

<Border Grid.Column="1" Height="100" />

Then the grid is rendered as expected.

An interesting observation is that if we set explicit width for the first column, which in my example has 1* width, then the problem disappears.

Metadata

Metadata

Assignees

Labels

InvestigateRequires further investigation by the WPF team.area-GridGrid issue/enhancements

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions