我尝试这样做但是我收到了消息错误:“ColumnDefinition不支持直接内容”
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="229">
<StackPanel Margin="0,0,0,17" Grid.ColumnSpan="2">
<TextBlock Height="30" Name="l1" Text="first name" />
<TextBox InputScope="Number" Height="71" Name="firstName" Text="" Width="460" />
</StackPanel>
</ColumnDefinition>
<ColumnDefinition Width="227">
<StackPanel Margin="0,0,0,17" Grid.ColumnSpan="2">
<TextBlock Height="30" Name="l1" Text="first name" />
<TextBox InputScope="Number" Height="71" Name="firstName" Text="" Width="460" />
</StackPanel>
</ColumnDefinition>
</Grid.ColumnDefinitions>
</Grid>
答案 0 :(得分:2)
你不能将内容直接放入列定义中,代码应该是---&gt;
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="229"></ColumnDefinition>
<ColumnDefinition Width="227"></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Margin="0,0,0,17" Grid.ColumnSpan="2">
<TextBlock Height="30" Name="l1" Text="first name" />
<TextBox InputScope="Number" Height="71" Name="firstName" Text="" Width="460" />
</StackPanel>
<StackPanel Grid.Column="1" Margin="0,0,0,17" Grid.ColumnSpan="2">
<TextBlock Height="30" Name="l1" Text="first name" />
<TextBox InputScope="Number" Height="71" Name="firstName" Text="" Width="460" />
</StackPanel>
</Grid>
你可以引用列号,其中具体内容位于Grid.Column = "nth Column"
之前{ - 1}}:Grid.Column = "0"