简体   繁体   English

WPF GridSplitter TabHeader定位

[英]WPF GridSplitter TabHeader Positioning

I have the following grid structure in my app: 我的应用程序具有以下网格结构:

点击这里查看结构

  • 3 Rows / 3 Columns: 3行/ 3列
    • Row 0 Col 0: TabControl with 3 TabItems 第0行第0行:具有3个TabItem的TabControl
    • Row 1 Col 0: GridSplitter 第1行第0行:GridSplitter
    • Row 2 Col 0: TabControl with 3 TabItems 第2行第0行:带有3个TabItem的TabControl
    • Row 0 Col 1: Gridsplitter 第0行第1列:Gridsplitter
    • Row 1 Col 1: - 第1行第1行:-
    • Row 2 Col 1: GridSplitter 第2行第1列:GridSplitter
    • Row 0 Col 2: AnyControls 第0行第2行:AnyControls
    • Row 1 Col 2: GridSplitter 第1行第2列:GridSplitter
    • Row 2 Col 2: AnyControls 第2行第2列:AnyControls

I want the 2 TabHeader Groups to be aligned side by side above the horizontal GridSplitter... 我希望2个TabHeader组在水平GridSplitter上方并排对齐...

Anyone any Ideas? 任何人有想法吗? I'm stuck here somehow... 我被卡在这里...

Set the Top Margin of the lower tab to a negative number to have it extend above of its location in the grid. 将下部选项卡的“上边距”设置为负数,以使其延伸到其在网格中位置的上方。 Place the GridSplitter beneath it, setting it to resize the rows and stretch horizontally (I used a blue background to make it visible). 将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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM