Перекрывающиеся сетки внутри вкладки - PullRequest
0 голосов
/ 22 сентября 2011

У меня есть две сетки внутри TabItem, и в коде позади я хочу иметь возможность добавлять элементы управления в обе сетки и иметь все элементы управления видимыми во время выполнения. В настоящее время во время выполнения элементы управления, добавленные в «Grid3», не отображаются, а элементы управления, добавленные в «Grid4», видны.

Перекрывающиеся сетки имеют одинаковые строки, но различный набор столбцов.

Я пытаюсь сделать это с двумя сетками, чтобы я мог изменить количество элементов управления, которые можно добавить для каждой строки в выделенном фрагменте кода, добавив элементы управления в одну из двух таблиц.

Вот XML:

 <Grid Name="TabControlGrid" Margin="20,171,0,70">
            <TabControl >
                <TabItem Header="Tab1" >
                    <Grid Name="InnerTabControlGrid">
                        <!--Start Grid3-->
                        <Grid Name="Grid3" Background="#FFE3EFFF" Height="188">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="98*" />
                                <ColumnDefinition Width="296*" />
                                <ColumnDefinition Width="88*" />
                                <ColumnDefinition Width="327*" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="10*" />
                                <RowDefinition Height="26*" />
                                <RowDefinition Height="26*" />
                                <RowDefinition Height="26*" />
                                <RowDefinition Height="26*" />
                                <RowDefinition Height="26*" />
                                <RowDefinition Height="26*" />
                                <RowDefinition Height="30*" />
                            </Grid.RowDefinitions>
                            <Grid Name="InnerGrid3" Grid.ColumnSpan="4" Grid.RowSpan="8" VerticalAlignment="Top" HorizontalAlignment="Left" Width="807">
                                <TextBlock Height="23" HorizontalAlignment="Left" Margin="10,10,0,0" Name="TextBlock1" Text="Row 1, Col 1" VerticalAlignment="Top" Width="71" Visibility="Collapsed"/>
                                <TextBlock Height="23" HorizontalAlignment="Left" Margin="10,35,0,0" Name="TextBlock2" Text="Row 2, Col 1" VerticalAlignment="Top" Width="71" Visibility="Collapsed"/>
                                <TextBlock Height="23" HorizontalAlignment="Left" Margin="10,60,0,0" Name="TextBlock3" Text="Row 3, Col 1" VerticalAlignment="Top" Width="71" Visibility="Collapsed"/>
                                <TextBlock Height="23" HorizontalAlignment="Left" Margin="10,85,0,0" Name="TextBlock4" Text="Row 4, Col 1" VerticalAlignment="Top" Width="71" Visibility="Collapsed"/>
                                <TextBlock Height="23" HorizontalAlignment="Left" Margin="10,110,0,0" Name="TextBlock5" Text="Row 5, Col 1" VerticalAlignment="Top" Width="71" Visibility="Collapsed"/>
                                <TextBlock Height="23" HorizontalAlignment="Left" Margin="10,135,0,0" Name="TextBlock6" Text="Row 6, Col 1" VerticalAlignment="Top" Width="71" Visibility="Collapsed"/>
                                <TextBlock Height="23" HorizontalAlignment="Left" Margin="10,160,0,0" Name="TextBlock7" Text="Row 7, Col 1" VerticalAlignment="Top" Width="71" Visibility="Collapsed"/>
                                <TextBlock Height="23" HorizontalAlignment="Left" Margin="405,10,0,0" Name="TextBlock8" Text="Row 1, Col 2" VerticalAlignment="Top" Width="71" Visibility="Collapsed"/>
                                <TextBlock Height="23" HorizontalAlignment="Left" Margin="405,35,0,0" Name="TextBlock9" Text="Row 2, Col 2" VerticalAlignment="Top" Width="71" Visibility="Collapsed"/>
                                <TextBlock Height="23" HorizontalAlignment="Left" Margin="405,60,0,0" Name="TextBlock10" Text="Row 3, Col 2" VerticalAlignment="Top" Width="71" Visibility="Collapsed"/>
                                <TextBlock Height="23" HorizontalAlignment="Left" Margin="405,85,0,0" Name="TextBlock11" Text="Row 4, Col 2" VerticalAlignment="Top" Width="71" Visibility="Collapsed"/>
                                <TextBlock Height="23" HorizontalAlignment="Left" Margin="405,110,0,0" Name="TextBlock12" Text="Row 5, Col 2" VerticalAlignment="Top" Width="71" Visibility="Collapsed"/>
                                <TextBlock Height="23" HorizontalAlignment="Left" Margin="403,135,0,0" Name="TextBlock13" Text="Row 6, Col 2:" VerticalAlignment="Top" Width="71" Visibility="Collapsed"/>
                                <TextBlock Height="23" HorizontalAlignment="Left" Margin="403,160,0,0" Name="TextBlock14" Text="Row 7, Col 2" VerticalAlignment="Top" Width="71" Visibility="Collapsed"/>
                                <ComboBox Height="23" HorizontalAlignment="Left" Margin="98,11,0,0" Name="ComboBox9" VerticalAlignment="Top" Width="291" Visibility="Collapsed"/>
                                <ComboBox Height="23" HorizontalAlignment="Left" Margin="479,10,0,0" Name="ComboBox10" VerticalAlignment="Top" Width="291" Visibility="Collapsed"/>
                                <ComboBox Height="23" HorizontalAlignment="Left" Margin="98,35,0,0" Name="ComboBox11" VerticalAlignment="Top" Width="291" Visibility="Collapsed"/>
                                <ComboBox Height="23" HorizontalAlignment="Left" Margin="479,35,0,0" Name="ComboBox12" VerticalAlignment="Top" Width="291" Visibility="Collapsed"/>
                                <ComboBox Height="23" HorizontalAlignment="Left" Margin="98,60,0,0" Name="ComboBox13" VerticalAlignment="Top" Width="291" Visibility="Collapsed"/>
                                <ComboBox Height="23" HorizontalAlignment="Left" Margin="479,60,0,0" Name="ComboBox14" VerticalAlignment="Top" Width="291" Visibility="Collapsed"/>
                                <ComboBox Height="23" HorizontalAlignment="Left" Margin="98,85,0,0" Name="ComboBox15" VerticalAlignment="Top" Width="291" Visibility="Collapsed"/>
                                <ComboBox Height="23" HorizontalAlignment="Left" Margin="479,85,0,0" Name="ComboBox16" VerticalAlignment="Top" Width="291" Visibility="Collapsed"/>
                                <ComboBox Height="23" HorizontalAlignment="Left" Margin="98,110,0,0" Name="ComboBox17" VerticalAlignment="Top" Width="291" Visibility="Collapsed"/>
                                <ComboBox Height="23" HorizontalAlignment="Left" Margin="479,111,0,0" Name="ComboBox18" VerticalAlignment="Top" Width="291" Visibility="Collapsed"/>
                                <ComboBox Height="23" HorizontalAlignment="Left" Margin="98,135,0,0" Name="ComboBox19" VerticalAlignment="Top" Width="291" Visibility="Collapsed"/>
                                <ComboBox Height="23" HorizontalAlignment="Left" Margin="479,136,0,0" Name="ComboBox20" VerticalAlignment="Top" Width="291" Visibility="Collapsed"/>
                                <ComboBox Height="23" HorizontalAlignment="Left" Margin="98,160,0,0" Name="ComboBox21" VerticalAlignment="Top" Width="291" Visibility="Collapsed"/>
                                <ComboBox Height="23" HorizontalAlignment="Left" Margin="479,160,0,0" Name="ComboBox22" VerticalAlignment="Top" Width="291" Visibility="Collapsed"/>
                              </Grid>
                        </Grid>

                        <!--End Grid3-->
                        <Grid Name="Grid4" Background="#FFE3EFFF">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="97*" />
                                <ColumnDefinition Width="102*" />
                                <ColumnDefinition Width="91*" />
                                <ColumnDefinition Width="102*" />
                                <ColumnDefinition Width="87*" />
                                <ColumnDefinition Width="102*" />
                                <ColumnDefinition Width="99*" />
                                <ColumnDefinition Width="125*" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="10*" />
                                <RowDefinition Height="26*" />
                                <RowDefinition Height="26*" />
                                <RowDefinition Height="26*" />
                                <RowDefinition Height="26*" />
                                <RowDefinition Height="26*" />
                                <RowDefinition Height="26*" />
                                <RowDefinition Height="30*" />
                            </Grid.RowDefinitions>
                            <Grid Name="InnerGrid4" Grid.ColumnSpan="8" Grid.RowSpan="8" VerticalAlignment="Top" HorizontalAlignment="Left" Width="803" Height="193">
                                <TextBlock Height="23" HorizontalAlignment="Left" Margin="10,10,0,0" Name="TextBlock15" Text="Row 1, Col 1" VerticalAlignment="Top" Width="73" Visibility="Collapsed" />
                                <TextBox BorderBrush="#FF898C95" Height="23" HorizontalAlignment="Left" Margin="98,11,0,0" Name="TextBox13a" VerticalAlignment="Top" Width="100" Visibility="Collapsed" />
                                <TextBlock Height="23" HorizontalAlignment="Left" Margin="210,10,0,0" Name="TextBlock16" Text="Row 1, Col 2" VerticalAlignment="Top" Width="73" Visibility="Collapsed" />
                                <TextBox BorderBrush="#FF898C95" Height="23" HorizontalAlignment="Left" Margin="289,11,0,0" Name="TextBox14a" VerticalAlignment="Top" Width="100" Visibility="Collapsed" />
                                <TextBlock Height="23" HorizontalAlignment="Left" Margin="410,12,0,0" Name="TextBlock17" Text="Row 1, Col 3" VerticalAlignment="Top" Width="67" Visibility="Collapsed" />
                                <ComboBox Height="23" HorizontalAlignment="Left" Margin="479,10,0,0" Name="ComboBox23" VerticalAlignment="Top" Width="100" Visibility="Collapsed" />
                                <TextBlock Height="23" HorizontalAlignment="Left" Margin="600,14,0,0" Name="TextBlock18" Text="Row 1, Col 4" VerticalAlignment="Top" Width="71" Visibility="Collapsed" />
                                <TextBox BorderBrush="#FF898C95" Height="23" HorizontalAlignment="Left" Margin="680,11,0,0" Name="TextBox18a" VerticalAlignment="Top" Width="100" Visibility="Collapsed" />
                                <TextBlock Height="23" HorizontalAlignment="Left" Margin="10,35,0,0" Name="TextBlock19" Text="Row 2, Col 1" VerticalAlignment="Top" Visibility="Collapsed" Width="73" />
                                <TextBox BorderBrush="#FF898C95" Height="23" HorizontalAlignment="Left" Margin="98,36,0,0" Name="TextBox1" VerticalAlignment="Top" Visibility="Collapsed" Width="100" />
                                <TextBlock Height="23" HorizontalAlignment="Left" Margin="210,35,0,0" Name="TextBlock20" Text="Row 2, Col 2" VerticalAlignment="Top" Visibility="Collapsed" Width="73" />
                                <TextBox BorderBrush="#FF898C95" Height="23" HorizontalAlignment="Left" Margin="289,36,0,0" Name="TextBox2" VerticalAlignment="Top" Visibility="Collapsed" Width="100" />
                                <TextBlock Height="23" HorizontalAlignment="Left" Margin="410,37,0,0" Name="TextBlock21" Text="Row 2, Col 3" VerticalAlignment="Top" Visibility="Collapsed" Width="67" />
                                <ComboBox Height="23" HorizontalAlignment="Left" Margin="479,35,0,0" Name="ComboBox24" VerticalAlignment="Top" Visibility="Collapsed" Width="100" />
                                <TextBlock Height="23" HorizontalAlignment="Left" Margin="600,39,0,0" Name="TextBlock22" Text="Row 2, Col 4" VerticalAlignment="Top" Visibility="Collapsed" Width="71" />
                                <TextBox BorderBrush="#FF898C95" Height="23" HorizontalAlignment="Left" Margin="680,36,0,0" Name="TextBox3" VerticalAlignment="Top" Visibility="Collapsed" Width="100" />
                            </Grid>
                        </Grid>
                    </Grid>
                </TabItem>
                <TabItem Header="Tab2" >
                </TabItem>
            </TabControl> 
        </Grid> 

Элементы управления в XML являются просто заполнителями для элементов управления, которые я добавляю к сеткам в выделенном фрагменте кода.

Если кто-нибудь может предложить решение, я буду признателен.

Спасибо!

-mg

Ответы [ 2 ]

0 голосов
/ 22 сентября 2011

Удалить фон из сетки. Вы не можете видеть сквозь сплошной цвет.

0 голосов
/ 22 сентября 2011

Ваш InnerTabControlGrid не определяет определения строк или столбцов, поэтому обе дочерние сетки размещаются друг над другом в одной ячейке сетки.

Измените InnerTabControlGrid на DockPanel или UniformGrid, или дайте ему Grid.ColumnDefinitions или Grid.RowDefinitions и присвойте вашей дочерней сетке Grid.Column или Grid.Row

...