我使用WPF(C#)。
我想Tab键TabControls位于底部。为此我使用了属性: TabStripPlacement =“Bottom”。
但是,由于我的风格,此属性不起作用:
<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>
请告诉我如何修复 标签TabControls 位于底部的 ?
答案 0 :(得分:2)
将Grid.Row="1"
移至<TabPanel...>
元素:
<TabPanel Grid.Row="1" IsItemsHost="True" />
<ContentPresenter ContentSource="SelectedContent"/>
然后,标签将显示在内容下方。
答案 1 :(得分:2)
将控制模板更新为:
<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>