Reputation: 1455
I use WPF (C #).
I want to tab TabControls were located at the bottom. For this I use the property: 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?
Upvotes: 1
Views: 4785
Reputation: 18580
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>
Upvotes: 3
Reputation:
Move Grid.Row="1"
to the <TabPanel...>
element:
<TabPanel Grid.Row="1" IsItemsHost="True" />
<ContentPresenter ContentSource="SelectedContent"/>
Then, the tabs will be shown below the content.
Upvotes: 2