Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 指定轴网柱的宽度_Wpf_Grid - Fatal编程技术网

Wpf 指定轴网柱的宽度

Wpf 指定轴网柱的宽度,wpf,grid,Wpf,Grid,我正在使用网格使用此列模板定义表单: <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="3*" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="3*" /> </Grid.ColumnDefinitions> <Label

我正在使用网格使用此列模板定义表单:

<Grid.ColumnDefinitions>
  <ColumnDefinition Width="*" />
  <ColumnDefinition Width="3*" />
  <ColumnDefinition Width="*" />
  <ColumnDefinition Width="3*" />
</Grid.ColumnDefinitions>
<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>
但我需要一个特定的行来使用另一个列模板:

<Grid.ColumnDefinitions>
  <ColumnDefinition Width="*" />
  <ColumnDefinition Width="3*" />
  <ColumnDefinition Width="*" />
  <ColumnDefinition Width="3*" />
</Grid.ColumnDefinitions>
<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>
前三个字段为1*,最后一个字段使用自由空间。 当然,我不能直接在字段中用百分比指定宽度


感谢您的帮助

您可以为特定行使用嵌套网格,该行跨越外部网格的所有四列:

<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>
注意,我假设当您引用1*时,您的意思是相对于您已经拥有的网格,即与第一列和第三列的大小相同。因此,这一行的总宽度为8*,我计算出这一行的相对宽度为1*,1*,1*,5*