0

已经开始自学 WPF,而不是继续使用 winforms。我还没有深入了解绑定的更详细方面,试图提前完成我的第一个运行界面,以便更好地了解 xaml 和文件背后的代码如何协同工作。无论如何,我正在尝试构建一个包含四行输入的表,每行 11 列,第 11 列是组合框。所有其他输入都是文本框。下面的代码生成一个边框厚度为 2 的表格。但是,由于我无法弄清楚的原因,当所有 xaml 定义都相同时,它还会在第 3 行和第 4 行之间产生间隙。

非常感谢可以提供的任何帮助,我为粗略的代码道歉 - 整理是议程上的重中之重。

注1;这个网格存在于另一个网格中。父行定义设置为自动

笔记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>
4

0 回答 0