nikotromus
nikotromus

Reputation: 1054

Need help on XAML Grid formatting the wrong way

I have the following xaml page that formats exactly as I would expect it to. The first two rows and the last row take up only the space that the elements allow for. Then, the third row takes up the remaining space on the page. Here is the xaml that works as expected:

<Grid>
    <!--Parent Grid-->
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"></ColumnDefinition>
    </Grid.ColumnDefinitions>

    <!--Parent Row 0-->
    <Grid Grid.Row="0" Margin="5">           
        <Label  Content="Auto Row 0"></Label>            
    </Grid>
    <!--Parent Row 1-->
    <Grid Grid.Row="1" Margin="5">
        <Label Content="Auto Row 1"></Label>
    </Grid>

    <!--Parent Row 2-->
    <Grid Grid.Row="2" Margin="5">
        <Label Content="Stretch Row 2"></Label>
    </Grid>

    <!--Parent Row 3-->
    <Grid Grid.Row="3" Margin="5">
        <Label Content="Auto Row 3"></Label>
    </Grid>
</Grid>

However, this page is loaded into the first row of the following grid. When it is loaded into this row, every row takes on the 'Auto' characteristic. So, each row is not scrunched up next to the other instead of the third row taking up all remaining space on the page.

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*" />
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <StackPanel>
        <Controls:SettingsTabControl Grid.Row="0" x:Name="mytab"></Controls:SettingsTabControl>
    </StackPanel>
    <Controls:SettingsFooter Grid.Row="1" />
</Grid> 

How do I fix this?

Upvotes: 0

Views: 53

Answers (1)

Marco
Marco

Reputation: 1016

Use a DockPanel instead of the Grid on the second part.

   <DockPanel x:Name="LayoutRoot">
        <Controls:SettingsFooter DockPanel.Dock="Bottom" />
        <Controls:SettingsTabControl x:Name="mytab" /> 
    </DockPanel>

Upvotes: 3

Related Questions