Search code examples
c#wpfwindows-phone-7xaml

Manage columnspan in a grid


Possible Duplicate:
Independants width in a WPF Grid

I would like to dispay 3 textBlocks on a grid (2 x 2)

I need to use columnspan but i can't do it right.

What i have :

enter image description here

What i want :

enter image description here

I tried several manipulation.

Here is my code :

<Grid Margin="20" VerticalAlignment="Top" HorizontalAlignment="Stretch">
 <Grid.RowDefinitions>
    <RowDefinition />
    <RowDefinition />
 </Grid.RowDefinitions>

 <Grid.ColumnDefinitions>
    <ColumnDefinition Width="*"/>
    <ColumnDefinition Width="*"/>
 </Grid.ColumnDefinitions>
 <TextBlock  Grid.Row="0" Grid.Column="0" Margin="0,0,10,0" x:Name="TxtBox_cCodeTiers" Text="{Binding m_strCode}" FontWeight="Bold" FontSize="22" />
 <TextBlock  Grid.Row="0" Grid.Column="1" Margin="0,0,10,0" x:Name="TxtBox_cNomTiers" Text="{Binding m_strNom}"   FontWeight="Bold" FontSize="22" />
 <TextBlock Grid.Row="1" Grid.Column="0" Margin="0,0,10,0" x:Name="TxtBox_cCPostal" TextWrapping="Wrap" Text="{Binding m_strFonction}" />
</Grid>

I know i need to use ColumnSpan but i tried and no result :(

Anyone could


Solution

  • Try adding Grid.ColumnSpan in the last TextBlock :

    <TextBlock  Grid.ColumnSpan="2" Grid.Row="1" Grid.Column="0" Margin="0,0,10,0" x:Name="TxtBox_cCPostal" TextWrapping="Wrap" Text="{Binding m_strFonction}" />