Najla August
Najla August

Reputation: 91

Grid rows are not expanding to fill window width

On my Wpf window I have a grid with two rows and two columns. The first row is set to span across both columns, and the second row contains two columns.

Here's the code:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"></RowDefinition>
        <RowDefinition></RowDefinition>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
    </Grid.ColumnDefinitions>
    <fluent:Ribbon x:Name="Ribbon" Grid.Row="0" Grid.ColumnSpan="2" HorizontalContentAlignment="Stretch">
        <!-- Ribbon code here -->
    </fluent:Ribbon>
    <StackPanel Grid.Row="1" Grid.Column="0">
        <local:LeftPane DataContext="{Binding}" />
    </StackPanel>
    <StackPanel Grid.Row="1" Grid.Column="1">
        <local:RightPane DataContext="{Binding}" />
    </StackPanel>
</Grid>

Here's the output:

my window
(source: unconventionalmommy.com)

Why are these two rows not stretching to fill the space on the right?

Upvotes: 0

Views: 911

Answers (1)

Najla August
Najla August

Reputation: 91

O joy -- Found the answer here:

http://www.wpftutorial.net/gridlayout.html

Changed Width from "Auto" to "*"

<ColumnDefinition Width="*" />

Upvotes: 1

Related Questions