简体   繁体   English

WPF底部的TabControl标签

[英]tab of TabControl at the bottom in WPF

I use WPF (C #). 我使用WPF(C#)。

I want to tab TabControls were located at the bottom. 我想选项卡TabControl位于底部。 For this I use the property: TabStripPlacement="Bottom" . 为此,我使用属性: TabStripPlacement =“ Bottom”

However, the this property does not work because of my style: 但是,由于我的风格,此属性不起作用:

<Grid>
 <Grid.Resources>
   <Style TargetType="{x:Type TabControl}">
     <Setter Property="Template">
       <Setter.Value>
         <ControlTemplate TargetType="{x:Type TabControl}">
           <Grid KeyboardNavigation.TabNavigation="Local">
             <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
             </Grid.RowDefinitions>

             <TabPanel IsItemsHost="True" />
             <ContentPresenter Grid.Row="1" ContentSource="SelectedContent"/>
           </Grid>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
   </Style>
 </Grid.Resources>

 <TabControl TabStripPlacement="Bottom" >
     <TabItem Header="tab1">fff</TabItem>
     <TabItem Header="tab2"></TabItem>
     <TabItem Header="tab3"></TabItem>
 </TabControl>

</Grid>

Please tell me, How can I fix that tabs TabControls located at the bottom ? 请告诉我, 如何修复位于底部的 TabControls选项卡

Move Grid.Row="1" to the <TabPanel...> element: Grid.Row="1"移动到<TabPanel...>元素:

<TabPanel Grid.Row="1" IsItemsHost="True" />
<ContentPresenter ContentSource="SelectedContent"/>

Then, the tabs will be shown below the content. 然后,选项卡将显示在内容下方。

Update your control template as: 将您的控制模板更新为:

     <Grid>
        <Grid.Resources>
            <Style TargetType="{x:Type TabControl}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type TabControl}">
                            <Grid KeyboardNavigation.TabNavigation="Local">
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
                                <ContentPresenter ContentSource="SelectedContent"/>
                                <TabPanel  Grid.Row="1" IsItemsHost="True" />

                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Grid.Resources>

        <TabControl TabStripPlacement="Bottom" >
            <TabItem Header="tab1">fff</TabItem>
            <TabItem Header="tab2"></TabItem>
            <TabItem Header="tab3"></TabItem>
        </TabControl>

    </Grid>

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

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