views:

739

answers:

1

So for example... in the following user control I have a grid with two rows. I want the bottom row to be the height of it's contents and the top row to be the height of the rest of the grid. I can set a absolute height as in the example, but that isn't particularly flexible. Say someone changes a font sizing the text could get clipped. Is there any built in way to achieve this?

<UserControl x:Class="Tournament.View.TeamCreator"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
    <Grid x:Name="LayoutRoot" Background="White" ShowGridLines="True">
        <Grid.RowDefinitions>
            <RowDefinition Height="1*" />
            <RowDefinition Height="20" />
        </Grid.RowDefinitions>

        <Grid Grid.Row="1" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1*" />
                <ColumnDefinition Width="1*" />
                <ColumnDefinition Width="1*" />
                <ColumnDefinition Width="1*" />
                <ColumnDefinition Width="1*" />
            </Grid.ColumnDefinitions>

            <Grid.RowDefinitions>
                <RowDefinition Height="1*" />
            </Grid.RowDefinitions>

            <TextBlock Grid.Column="0" Grid.Row="0" Text="TEAM NAME" />
            <TextBox Grid.Column="1" Grid.Row="0" />
            <TextBlock Grid.Column="2" Grid.Row="0" Text="MANAGER NAME" />
            <TextBox Grid.Column="3" Grid.Row="0" />
            <Button Grid.Column="4" Grid.Row="0" />
        </Grid>
    </Grid>
</UserControl>
+1  A: 

In WPF this is as simple as:

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

I suspect the same works in Silverlight?

Dave
Sweet works a treat, cheers
James Hay