Ask Your Question

Revision history [back]

You can set the HorizontalAlignment property of each control in the grid row to "Stretch". This will cause the controls to resize horizontally to occupy the entire width of the grid row.

Here is an example XAML code snippet that demonstrates this:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>

    <Label Content="Label 1" Grid.Row="0" HorizontalAlignment="Stretch"/>
    <TextBox Text="TextBox 1" Grid.Row="1" HorizontalAlignment="Stretch"/>
    <Button Content="Button 1" Grid.Row="2" HorizontalAlignment="Stretch"/>
</Grid>

In this example, the HorizontalAlignment property of each control in the grid row is set to "Stretch", which causes them to resize horizontally to occupy the entire width of the grid row.