Reputation: 3706
I have a TabControl
like so:
<TabControl ItemsSource="{Binding TabItems, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
SelectedIndex="0"
BorderThickness="0"
TabStripPlacement="Left"
Padding="10,0,0,10">
<TabControl.ItemContainerStyle>
<Style TargetType="TabItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TabItem">
<Grid Name="Panel">
<ContentPresenter x:Name="ContentSite" VerticalAlignment="Center" HorizontalAlignment="Center" ContentSource="Header" Margin="20,5"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Panel" Property="Background" Value="#d9534f" />
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter TargetName="Panel" Property="Background" Value="#E6E3DB" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Header" Value="{Binding Header, Mode=OneTime}"/>
<Setter Property="Content" Value="{Binding Content, Mode=OneTime}"/>
</Style>
</TabControl.ItemContainerStyle>
</TabControl>
Is there a way to change the color of the Panel
where TabItems
are located:
Thank you for any suggestions.
Upvotes: 1
Views: 1759
Reputation: 10393
EDIT after OP clarified the question.
The are you refer to has nothing to do with the TabItem
or even the TabControl
. It's simply the control where the TabControl
resides in.
Please see the following simple example:
<Window x:Class="StackOverflowWPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:StackOverflowWPF"
mc:Ignorable="d"
Title="MainWindow" Height="200" Width="300">
<Grid Background="LightSeaGreen">
<TabControl Background="Red">
<TabItem Header="Tab1" Background="Yellow">
</TabItem>
<TabItem Header="Tab1" Background="Green">
</TabItem>
</TabControl>
</Grid>
</Window>
And this is what it looks like in the designer:
So going back to your example, I'm assuming you want to set the color of area pointed to by an arrow, while keeping the rest of the form in a different color. I'd make use of the Grid
control for that.
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Background="LightGreen">
<TabControl Grid.Row="0" Background="Red" Height="100">
<TabItem Header="Tab1" Background="Yellow">
</TabItem>
<TabItem Header="Tab1" Background="Green">
</TabItem>
</TabControl>
</Grid>
<Grid Grid.Row="1"/>
</Grid>
And it will look like this:
Upvotes: 1