我的应用程序具有以下网格结构:
我希望2个TabHeader组在水平GridSplitter上方并排对齐...
有人有想法吗?我被卡在这里...
答案 0 :(得分:1)
将下部选项卡的“上边距”设置为负数,以使其延伸到其在网格中位置的上方。将GridSplitter放置在其下方,设置其大小以调整行的大小并水平拉伸(我使用蓝色背景使其可见)。
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition Width="10"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition Height="10"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<!-- Set the GridSplitter's ResizeDirection to Rows, and its HorizontalAlignment to Stretch -->
<GridSplitter Grid.Row="1" Grid.Column="0" Height="2" ResizeDirection="Rows" HorizontalAlignment="Stretch" Background="Blue"></GridSplitter>
<!-- Place the upper TabControl's tabs on the bottom and aligned to the right. -->
<TabControl Grid.Column="0" Grid.Row="0" TabStripPlacement="Bottom">
<TabControl.Resources>
<Style TargetType="TabPanel">
<Setter Property="HorizontalAlignment" Value="Right"/>
</Style>
</TabControl.Resources>
<TabItem Header="Item 1"></TabItem>
<TabItem Header="Item 2"></TabItem>
<TabItem Header="Item 3"></TabItem>
</TabControl>
<!-- Set the lower TabControl's top margin to -30 to extend up out of its location in the grid. -->
<TabControl Grid.Column="0" Grid.Row="2" Margin="0, -30, 0, 0">
<TabItem Header="Item 1"></TabItem>
<TabItem Header="Item 2"></TabItem>
<TabItem Header="Item 3"></TabItem>
</TabControl>
</Grid>