继续自学WPF,而不是继续使用winforms。我还没有进入更详细的绑定方面,试图预先完成我的第一个运行界面,这样我就能更好地掌握xaml和代码隐藏文件如何协同工作。无论如何,我正在尝试构建一个包含四行输入的表,每行有11列,第11列是组合框。所有其他输入都是文本框。下面的代码生成一个边框全部为厚度为2的表。但是,由于我无法弄清楚的原因,当所有xaml定义相同时,它也会在第3行和第4行之间产生间隙。
非常感谢任何可以提供的帮助,我为粗略的代码道歉 - 整理议程上的重点。
注1;这个网格生活在另一个网格中。父行定义设置为auto
注2;如果我在设计器中将页面设计扩展到此网格之外,它在设计时会呈现正常,但在进入调试时会出现间隙。
注3;我将代码复制到VS2012的另一个实例中,它似乎在设计和调试中都能正常工作....
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition MinWidth="30"/>
<ColumnDefinition MinWidth="30"/>
<ColumnDefinition MinWidth="30"/>
<ColumnDefinition MinWidth="30"/>
<ColumnDefinition MinWidth="30"/>
<ColumnDefinition MinWidth="30"/>
<ColumnDefinition MinWidth="30"/>
<ColumnDefinition MinWidth="30"/>
<ColumnDefinition MinWidth="30"/>
<ColumnDefinition MinWidth="75"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Label Grid.Column="0" FontWeight="Bold" BorderBrush="Black" BorderThickness="2,2,1,1">A</Label>
<Label Grid.Column="1" FontWeight="Bold" BorderBrush="Black" BorderThickness="1,2,1,1" HorizontalContentAlignment="Center">B</Label>
<Label Grid.Column="2" FontWeight="Bold" BorderBrush="Black" BorderThickness="1,2,1,1" HorizontalContentAlignment="Center">C</Label>
<Label Grid.Column="3" FontWeight="Bold" BorderBrush="Black" BorderThickness="1,2,1,1" HorizontalContentAlignment="Center">D</Label>
<Label Grid.Column="4" FontWeight="Bold" BorderBrush="Black" BorderThickness="1,2,1,1" HorizontalContentAlignment="Center">E</Label>
<Label Grid.Column="5" FontWeight="Bold" BorderBrush="Black" BorderThickness="1,2,1,1" HorizontalContentAlignment="Center">F</Label>
<Label Grid.Column="6" FontWeight="Bold" BorderBrush="Black" BorderThickness="1,2,1,1" HorizontalContentAlignment="Center">G</Label>
<Label Grid.Column="7" FontWeight="Bold" BorderBrush="Black" BorderThickness="1,2,1,1" HorizontalContentAlignment="Center">H</Label>
<Label Grid.Column="8" FontWeight="Bold" BorderBrush="Black" BorderThickness="1,2,1,1" HorizontalContentAlignment="Center">I</Label>
<Label Grid.Column="9" FontWeight="Bold" BorderBrush="Black" BorderThickness="1,2,1,1" HorizontalContentAlignment="Center">J</Label>
<Label Grid.Column="10" FontWeight="Bold" BorderBrush="Black" BorderThickness="1,2,2,1" HorizontalContentAlignment="Center">K</Label>
<TextBox Grid.Column="0" Grid.Row="1" BorderBrush="Black" BorderThickness="2,1,1,1" Padding="1" MinWidth="150"/>
<TextBox Grid.Column="1" Grid.Row="1" BorderBrush="Black" BorderThickness="1" Padding="1"/>
<TextBox Grid.Column="2" Grid.Row="1" BorderBrush="Black" BorderThickness="1" Padding="1"/>
<TextBox Grid.Column="3" Grid.Row="1" BorderBrush="Black" BorderThickness="1" Padding="1"/>
<TextBox Grid.Column="4" Grid.Row="1" BorderBrush="Black" BorderThickness="1" Padding="1"/>
<TextBox Grid.Column="5" Grid.Row="1" BorderBrush="Black" BorderThickness="1" Padding="1"/>
<TextBox Grid.Column="6" Grid.Row="1" BorderBrush="Black" BorderThickness="1" Padding="1"/>
<TextBox Grid.Column="7" Grid.Row="1" BorderBrush="Black" BorderThickness="1" Padding="1"/>
<TextBox Grid.Column="8" Grid.Row="1" BorderBrush="Black" BorderThickness="1" Padding="1"/>
<TextBox Grid.Column="9" Grid.Row="1" BorderBrush="Black" BorderThickness="1" Padding="1"/>
<ComboBox Grid.Column="10" Grid.Row="1">
<!--Combobox items-->
</Combobox>
<TextBox Grid.Column="0" Grid.Row="2" BorderBrush="Black" BorderThickness="2,1,1,1" Padding="1" MinWidth="150"/>
<TextBox Grid.Column="1" Grid.Row="2" BorderBrush="Black" BorderThickness="1" Padding="1"/>
<TextBox Grid.Column="2" Grid.Row="2" BorderBrush="Black" BorderThickness="1" Padding="1"/>
<TextBox Grid.Column="3" Grid.Row="2" BorderBrush="Black" BorderThickness="1" Padding="1"/>
<TextBox Grid.Column="4" Grid.Row="2" BorderBrush="Black" BorderThickness="1" Padding="1"/>
<TextBox Grid.Column="5" Grid.Row="2" BorderBrush="Black" BorderThickness="1" Padding="1"/>
<TextBox Grid.Column="6" Grid.Row="2" BorderBrush="Black" BorderThickness="1" Padding="1"/>
<TextBox Grid.Column="7" Grid.Row="2" BorderBrush="Black" BorderThickness="1" Padding="1"/>
<TextBox Grid.Column="8" Grid.Row="2" BorderBrush="Black" BorderThickness="1" Padding="1"/>
<TextBox Grid.Column="9" Grid.Row="2" BorderBrush="Black" BorderThickness="1" Padding="1"/>
<ComboBox Grid.Column="10" Grid.Row="2">
<!-- Combobox items -->
</ComboBox>
<TextBox Grid.Column="0" Grid.Row="3" BorderBrush="Black" BorderThickness="2,1,1,1" Padding="1" MinWidth="150" Visibility="Visible"/>
<TextBox Grid.Column="1" Grid.Row="3" BorderBrush="Black" BorderThickness="1" Padding="1" Visibility="Visible"/>
<TextBox Grid.Column="2" Grid.Row="3" BorderBrush="Black" BorderThickness="1" Padding="1" Visibility="Visible"/>
<TextBox Grid.Column="3" Grid.Row="3" BorderBrush="Black" BorderThickness="1" Padding="1" Visibility="Visible"/>
<TextBox Grid.Column="4" Grid.Row="3" BorderBrush="Black" BorderThickness="1" Padding="1" Visibility="Visible"/>
<TextBox Grid.Column="5" Grid.Row="3" BorderBrush="Black" BorderThickness="1" Padding="1" Visibility="Visible"/>
<TextBox Grid.Column="6" Grid.Row="3" BorderBrush="Black" BorderThickness="1" Padding="1" Visibility="Visible"/>
<TextBox Grid.Column="7" Grid.Row="3" BorderBrush="Black" BorderThickness="1" Padding="1" Visibility="Visible"/>
<TextBox Grid.Column="8" Grid.Row="3" BorderBrush="Black" BorderThickness="1" Padding="1" Visibility="Visible"/>
<TextBox Grid.Column="9" Grid.Row="3" BorderBrush="Black" BorderThickness="1" Padding="1" Visibility="Visible"/>
<ComboBox Grid.Column="10" Grid.Row="3" Visibility="Visible">
<!-- Combobox items -->
</ComboBox>
<TextBox Grid.Column="0" Grid.Row="4" BorderBrush="Black" BorderThickness="2,1,1,2" Padding="1" MinWidth="150"/>
<TextBox Grid.Column="1" Grid.Row="4" BorderBrush="Black" BorderThickness="1,1,1,2" Padding="1"/>
<TextBox Grid.Column="2" Grid.Row="4" BorderBrush="Black" BorderThickness="1,1,1,2" Padding="1"/>
<TextBox Grid.Column="3" Grid.Row="4" BorderBrush="Black" BorderThickness="1,1,1,2" Padding="1"/>
<TextBox Grid.Column="4" Grid.Row="4" BorderBrush="Black" BorderThickness="1,1,1,2" Padding="1"/>
<TextBox Grid.Column="5" Grid.Row="4" BorderBrush="Black" BorderThickness="1,1,1,2" Padding="1"/>
<TextBox Grid.Column="6" Grid.Row="4" BorderBrush="Black" BorderThickness="1,1,1,2" Padding="1"/>
<TextBox Grid.Column="7" Grid.Row="4" BorderBrush="Black" BorderThickness="1,1,1,2" Padding="1"/>
<TextBox Grid.Column="8" Grid.Row="4" BorderBrush="Black" BorderThickness="1,1,1,2" Padding="1"/>
<TextBox Grid.Column="9" Grid.Row="4" BorderBrush="Black" BorderThickness="1,1,1,2" Padding="1"/>
<ComboBox Grid.Column="10" Grid.Row="4">
<!-- Combobox items -->
</ComboBox>
</Grid>