Reputation:
I'm using a grid to define a form with this column template :
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="3*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="3*" />
</Grid.ColumnDefinitions>
But I need for a specific row to use another column template :
<Label Grid.Column="0" Grid.Row="4">N°</Label>
<TextBox Grid.Column="1" Grid.Row="4" Name="idNum"></TextBox>
<ComboBox Grid.Column="2" Grid.Row="4" Name="idVoie" SelectedValuePath="Key" DisplayMemberPath="Value" SelectedValue="."></ComboBox>
<TextBox Grid.Column="3" Grid.Row="4" Name="idAdr"></TextBox>
with the first three field being 1*
and the last field using the free space.
Of course, I can't specify the width directly in the field with percent.
Thanks for your help
Upvotes: 0
Views: 48
Reputation: 116528
You can use a nested grid for that particular row, which spans all four columns of your outer grid:
<Grid Grid.Column="0" Grid.Row="4" Grid.ColumnSpan="4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="5*" />
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Grid.Row="0">N°</Label>
<TextBox Grid.Column="1" Grid.Row="0" Name="idNum"></TextBox>
<ComboBox Grid.Column="2" Grid.Row="0" Name="idVoie" SelectedValuePath="Key" DisplayMemberPath="Value" SelectedValue="."></ComboBox>
<TextBox Grid.Column="3" Grid.Row="0" Name="idAdr"></TextBox>
</Grid>
Note I'm assuming when you refer to 1*
you mean as relative to the grid you already have, i.e. the same size as the first and third columns. Therefore you have a total of 8*
across the row, and I've calculated the relative widths for your row to be 1*
, 1*
, 1*
, 5*
.
Upvotes: 1