0

I have relectively complex gui, but it cannot display my the whole controls(in the code, it cannot display "EMAIL", "FORWARD",...) on the bottom. what's wrong with this code? Is it because the "Window", "TabControl" or "ScrollViewer".

Thank you so much in advance!

the code is as below:

<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    ShowInTaskbar="False" WindowStartupLocation="CenterOwner" 
    SizeToContent="Height" Title="Window1">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
        <TabControl Name="tabControl1" Grid.Row="0">
            <TabItem Header="A">
                <Grid Margin="5,5,5,5">
                    <StackPanel>
                        <Grid>
                            <TabControl>
                                <TabItem Header="A1">
                                    <Grid Margin="5,5,5,5">
                                        <Grid.RowDefinitions>
                                            <RowDefinition />
                                            <RowDefinition />
                                            <RowDefinition Height="10"  />
                                            <RowDefinition/>
                                        </Grid.RowDefinitions>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="auto" />
                                            <ColumnDefinition Width="auto" />
                                            <ColumnDefinition Width="auto" />
                                        </Grid.ColumnDefinitions>
                                        <StackPanel Name="spG11" Grid.Row="0" Grid.Column="0" Margin="5,5,5,5">
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="25"/>
                                                    <RowDefinition Height="25" />
                                                    <RowDefinition Height="25" />
                                                    <RowDefinition Height="25" />
                                                    <RowDefinition Height="25" />
                                                </Grid.RowDefinitions>
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="130"/>
                                                    <ColumnDefinition Width="150"/>
                                                </Grid.ColumnDefinitions>
                                                <TextBlock Grid.Row="0" Grid.Column="0" Text="A11" VerticalAlignment="Center" />
                                                <TextBox Grid.Row="0" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
                                                <TextBlock Grid.Row="1" Grid.Column="0" Text="A12" VerticalAlignment="Center" />
                                                <TextBox Grid.Row="1" Grid.Column="1"  HorizontalAlignment="Stretch" VerticalAlignment="Center" />
                                                <TextBlock Grid.Row="2" Grid.Column="0" Text="A13" VerticalAlignment="Center" />
                                                <TextBox Grid.Row="2" Grid.Column="1"  HorizontalAlignment="Stretch" VerticalAlignment="Center" />
                                                <TextBlock Grid.Row="3" Grid.Column="0" Text="A14" VerticalAlignment="Center" />
                                                <TextBox Grid.Row="3" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
                                                <TextBlock Grid.Row="4" Grid.Column="0" Text="A15" VerticalAlignment="Center" />
                                                <TextBox Grid.Row="4" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
                                            </Grid>
                                        </StackPanel>
                                        <StackPanel Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" Margin="5,5,5,5">
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="25" />
                                                    <RowDefinition Height="25" />
                                                    <RowDefinition Height="25" />
                                                    <RowDefinition Height="25" />
                                                    <RowDefinition Height="25" />
                                                </Grid.RowDefinitions>
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="130"/>
                                                    <ColumnDefinition Width="150"/>
                                                </Grid.ColumnDefinitions>
                                                <TextBlock Grid.Row="0" Grid.Column="0" Text="A21" VerticalAlignment="Center" />
                                                <TextBox Grid.Row="0" Grid.Column="1"  HorizontalAlignment="Stretch" VerticalAlignment="Center" />
                                                <TextBlock Grid.Row="1" Grid.Column="0" Text="A22" VerticalAlignment="Center" />
                                                <TextBox Grid.Row="1" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
                                                <TextBlock Grid.Row="2" Grid.Column="0" Text="A23" VerticalAlignment="Center" />
                                                <TextBox Grid.Row="2" Grid.Column="1"  HorizontalAlignment="Stretch" VerticalAlignment="Center" />
                                                <TextBlock Grid.Row="3" Grid.Column="0" Text="A24" VerticalAlignment="Center" />
                                                <ComboBox Grid.Row="3" Grid.Column="1"  IsEnabled="False" HorizontalAlignment="Stretch" VerticalAlignment="Center">
                                                    <ComboBoxItem Content="False" IsSelected="True" IsEnabled="False"></ComboBoxItem>
                                                    <ComboBoxItem Content="True"></ComboBoxItem>
                                                </ComboBox>
                                                <TextBlock Grid.Row="4" Grid.Column="0" Text="A25" VerticalAlignment="Center" />
                                                <ComboBox Grid.Row="4" Grid.Column="1" IsEnabled="False" HorizontalAlignment="Stretch" VerticalAlignment="Center">
                                                    <ComboBoxItem Content="False" IsSelected="True" IsEnabled="False"></ComboBoxItem>
                                                    <ComboBoxItem Content="True"></ComboBoxItem>
                                                </ComboBox>
                                            </Grid>
                                        </StackPanel>
                                        <Border BorderThickness="1" BorderBrush="Gray" Grid.Row="1" Grid.Column="0">
                                            <StackPanel >
                                                <StackPanel>
                                                    <Grid>
                                                        <Grid.RowDefinitions>
                                                            <RowDefinition Height="*" />
                                                            <RowDefinition Height="*" />
                                                        </Grid.RowDefinitions>
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition Width="40"/>
                                                            <ColumnDefinition Width="105"/>
                                                            <ColumnDefinition Width="120"/>
                                                        </Grid.ColumnDefinitions>
                                                        <TextBox Height="25" HorizontalAlignment="Stretch" IsReadOnly="True" Text="X1" TextAlignment="Center" Background="LightBlue" Grid.Row="0" Grid.Column="0"/>
                                                        <TextBox HorizontalAlignment="Stretch" Text="X2" IsReadOnly="True" TextAlignment="Center" Background="LightBlue" Grid.Row="0" Grid.Column="1"/>
                                                        <TextBox Height="25" HorizontalAlignment="Stretch" IsReadOnly="True" Text="X3" TextAlignment="Center" Background="LightBlue" Grid.Row="0" Grid.Column="2"/>
                                                    </Grid>
                                                </StackPanel>
                                                    <ScrollViewer HorizontalAlignment="Left" VerticalScrollBarVisibility="Visible"  Height="150">
                                                    <StackPanel>
                                                        <Grid >
                                                            <Grid.RowDefinitions>
                                                            </Grid.RowDefinitions>
                                                            <Grid.ColumnDefinitions>
                                                                <ColumnDefinition Width="40"/>
                                                                <ColumnDefinition Width="105"/>
                                                                <ColumnDefinition Width="120"/>
                                                            </Grid.ColumnDefinitions>
                                                        </Grid>
                                                    </StackPanel>
                                                </ScrollViewer>
                                            </StackPanel>
                                        </Border>
                                        <StackPanel Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" >
                                            <Button  Margin="2,2,2,2" Content="ADD"  Width="50"/>
                                            <Button  Margin="2,2,2,2" Content="DEL"  Width="50" />
                                        </StackPanel>

                                        <Border BorderThickness="1" BorderBrush="Gray" Grid.Row="1" Grid.Column="2">
                                            <StackPanel HorizontalAlignment="Left">
                                                <StackPanel>
                                                    <Grid>
                                                        <Grid.RowDefinitions>
                                                            <RowDefinition Height="*" />
                                                            <RowDefinition Height="*" />
                                                        </Grid.RowDefinitions>
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition Width="50"/>
                                                            <ColumnDefinition Width="50"/>
                                                            <ColumnDefinition Width="50"/>
                                                            <ColumnDefinition Width="50"/>
                                                        </Grid.ColumnDefinitions>
                                                        <TextBox Height="25" HorizontalAlignment="Stretch" IsReadOnly="True" Text="Y1" TextAlignment="Center" Background="LightBlue" Name="VaAmplitude" Grid.Row="0" Grid.Column="0"/>
                                                        <TextBox HorizontalAlignment="Stretch" Text="Y2" IsReadOnly="True" TextAlignment="Center" Background="LightBlue" Name="VaPhase" Grid.Row="0" Grid.Column="1"/>
                                                        <TextBox Height="25" HorizontalAlignment="Stretch" IsReadOnly="True" Text="Y3" TextAlignment="Center" Background="LightBlue" Name="VbAmplitude" Grid.Row="0" Grid.Column="2"/>
                                                        <TextBox HorizontalAlignment="Stretch" Text="Y4" IsReadOnly="True" TextAlignment="Center" Background="LightBlue" Name="VbPhase" Grid.Row="0" Grid.Column="3"/>
                                                    </Grid>
                                                </StackPanel>
                                                <ScrollViewer HorizontalAlignment="Left" VerticalScrollBarVisibility="Visible" Height="150">
                                                    <Grid >
                                                        <Grid.RowDefinitions>
                                                        </Grid.RowDefinitions>
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition Width="50"/>
                                                            <ColumnDefinition Width="50"/>
                                                            <ColumnDefinition Width="50"/>
                                                            <ColumnDefinition Width="50"/>
                                                        </Grid.ColumnDefinitions>
                                                    </Grid>
                                                </ScrollViewer>
                                            </StackPanel>
                                        </Border>

                                        <StackPanel Grid.Row="3" Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
                                            <CheckBox Content="SELECT" IsChecked="True"/>
                                            <TextBlock Width="12" />
                                            <CheckBox Content="FORWARD" IsChecked="False"/>
                                        </StackPanel>
                                        <StackPanel Grid.Row="3" Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Center">
                                            <Button Content="LIST" />
                                        </StackPanel>
                                    </Grid>
                                </TabItem>

                            </TabControl>
                        </Grid>
                    </StackPanel>
                </Grid>
            </TabItem>
            <!--  -->
            <TabItem Header="B">
                <Grid Margin="5,5,5,5">
                    <StackPanel>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            <TabControl Grid.Row="0">
                                <TabItem Header="B1">
                                    <Grid Margin="5,5,5,5">
                                        <Grid.RowDefinitions>
                                            <RowDefinition />
                                            <RowDefinition />
                                            <RowDefinition Height="10"  />
                                            <RowDefinition/>
                                        </Grid.RowDefinitions>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="auto" />
                                            <ColumnDefinition Width="auto" />
                                            <ColumnDefinition Width="auto" />
                                            <ColumnDefinition Width="auto" />
                                        </Grid.ColumnDefinitions>
                                        <StackPanel Name="spU11" Grid.Row="0" Grid.Column="0" Margin="5,5,5,5">
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="25"/>
                                                    <RowDefinition Height="25" />
                                                    <RowDefinition Height="25" />
                                                    <RowDefinition Height="25" />
                                                    <RowDefinition Height="25" />
                                                    <RowDefinition Height="25" />
                                                </Grid.RowDefinitions>
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="130"/>
                                                    <ColumnDefinition Width="150"/>
                                                </Grid.ColumnDefinitions>
                                                <TextBlock Grid.Row="0" Grid.Column="0" Text="B11" VerticalAlignment="Center" />
                                                <TextBox Grid.Row="0" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
                                                <TextBlock Grid.Row="1" Grid.Column="0" Text="B12" VerticalAlignment="Center" />
                                                <TextBox Grid.Row="1" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
                                                <TextBlock Grid.Row="2" Grid.Column="0" Text="B13" VerticalAlignment="Center" />
                                                <TextBox Grid.Row="2" Grid.Column="1"  HorizontalAlignment="Stretch" VerticalAlignment="Center" />
                                                <TextBlock Grid.Row="3" Grid.Column="0" Text="B14" VerticalAlignment="Center" />
                                                <TextBox Grid.Row="3" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
                                                <TextBlock Grid.Row="4" Grid.Column="0" Text="B15" VerticalAlignment="Center" />
                                                <TextBox Grid.Row="4" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
                                                <TextBlock Grid.Row="5" Grid.Column="0" Text="B16" VerticalAlignment="Center" />
                                                <TextBox Grid.Row="5" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
                                            </Grid>
                                        </StackPanel>
                                        <StackPanel Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" Margin="5,5,5,5">
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="25" />
                                                    <RowDefinition Height="25" />
                                                    <RowDefinition Height="25" />
                                                    <RowDefinition Height="25" />
                                                    <RowDefinition Height="25" />
                                                    <RowDefinition Height="25" />
                                                </Grid.RowDefinitions>
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="130"/>
                                                    <ColumnDefinition Width="150"/>
                                                </Grid.ColumnDefinitions>
                                                <TextBlock Grid.Row="0" Grid.Column="0" Text="B21" VerticalAlignment="Center" />
                                                <TextBox Grid.Row="0" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
                                                <TextBlock Grid.Row="1" Grid.Column="0" Text="B22" VerticalAlignment="Center" />
                                                <TextBox Grid.Row="1" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
                                                <TextBlock Grid.Row="2" Grid.Column="0" Text="B23" VerticalAlignment="Center" />
                                                <TextBox Grid.Row="2" Grid.Column="1"  HorizontalAlignment="Stretch" VerticalAlignment="Center" />
                                                <TextBlock Grid.Row="4" Grid.Column="0" Text="B24" VerticalAlignment="Center" />
                                                <TextBox Grid.Row="4" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
                                                <TextBlock Grid.Row="5" Grid.Column="0" Text="B25" VerticalAlignment="Center" />
                                                <TextBox Grid.Row="5" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
                                            </Grid>
                                        </StackPanel>
                                        <Border BorderThickness="1" BorderBrush="Gray" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2">
                                            <StackPanel>
                                                <StackPanel>
                                                    <Grid>
                                                        <Grid.RowDefinitions>
                                                            <RowDefinition Height="*" />
                                                            <RowDefinition Height="*" />
                                                        </Grid.RowDefinitions>
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition Width="60"/>
                                                            <ColumnDefinition Width="172"/>
                                                            <ColumnDefinition Width="170"/>
                                                        </Grid.ColumnDefinitions>
                                                        <TextBox Height="25" HorizontalAlignment="Stretch" IsReadOnly="True" Text="Q1" TextAlignment="Center" Background="LightBlue" Grid.Row="0" Grid.Column="0"/>
                                                        <TextBox HorizontalAlignment="Stretch" Text="Q2" IsReadOnly="True" TextAlignment="Center" Background="LightBlue" Grid.Row="0" Grid.Column="1"/>
                                                        <TextBox Height="25" HorizontalAlignment="Stretch" IsReadOnly="True" Text="Q3" TextAlignment="Center" Background="LightBlue" Grid.Row="0" Grid.Column="2"/>
                                                    </Grid>
                                                </StackPanel>
                                                <ScrollViewer HorizontalAlignment="Left" VerticalScrollBarVisibility="Visible" Height="150">
                                                    <Grid>
                                                        <Grid.RowDefinitions>
                                                        </Grid.RowDefinitions>
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition Width="60"/>
                                                            <ColumnDefinition Width="172"/>
                                                            <ColumnDefinition Width="170"/>
                                                        </Grid.ColumnDefinitions>
                                                    </Grid>
                                                </ScrollViewer>
                                            </StackPanel>
                                        </Border>
                                        <StackPanel Grid.Row="1" Grid.Column="2" VerticalAlignment="Center" >
                                            <Button Margin="2,2,2,2" Content="ADD"  Width="60"/>
                                            <Button  Margin="2,2,2,2" Content="DEL"  Width="60" />
                                        </StackPanel>
                                        <StackPanel Grid.Row="3" Grid.ColumnSpan="3">
                                            <CheckBox Content="FORWARD" IsChecked="True" />
                                        </StackPanel>

                                    </Grid>
                                </TabItem>

                            </TabControl>

                            <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center">
                                <StackPanel Grid.Row="3" Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
                                    <TextBlock Text="EMAIL" />
                                    <TextBox Width="80"/>
                                </StackPanel>
                                <TextBlock Width="30" />
                                <StackPanel Grid.Row="3" Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
                                    <TextBlock Text="PAT NO" />
                                    <TextBox Width="80"/>
                                </StackPanel>
                            </StackPanel>
                        </Grid>
                    </StackPanel>
                </Grid>
            </TabItem>
        </TabControl>
        <StackPanel Grid.Row="1" HorizontalAlignment="Stretch" Name="testItemLabelValue" Visibility="Hidden">
            <TextBox Margin="0,1,0,1" HorizontalAlignment="Stretch" />
            <StackPanel x:Name="labelling"></StackPanel>
        </StackPanel>
        <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Height="50">
            <Button Content="YES" Width="70" Height="25" HorizontalAlignment="Right" Margin="0,0,20,0" />
            <TextBox Margin="0,1,0,1" HorizontalAlignment="Stretch" Visibility="Hidden" />
            <Button Content="CANCEAL" Width="70" Height="25" HorizontalAlignment="Left"/>
        </StackPanel>
    </Grid>
</Window>
4

1 回答 1

1

您只需要指定顶部网格的高度,如下所示:

<Grid.RowDefinitions>
    <RowDefinition Height="Auto" />
    <RowDefinition Height="Auto" />
</Grid.RowDefinitions>

我正在尝试你的用户界面,现在它可以工作了。

PS 虽然这可以让您的 UI 正常工作,但我会鼓励您阅读有关用户控件的内容,并尝试通过使用它们(分而治之)来降低整个 UI 的复杂性。

于 2012-09-06T01:37:15.493 回答