Tabitem wpf как изменить цвет

How do I set the background color of a TabItem in a TabControl?
  • Remove From My Forums
  • Question

  • How do I set the background color of a TabItem in a TabControl?

    When I do this . . .

            <TabControl Background=»#FFD0FFD0″>
                <TabItem x:Name=»Tab1″ Background=»#FFD0D0F0″>
                    <TabItem.Header>
                        <TextBlock x:Name=»Tab1TextBlock» Background=»#FFFFFFFF»> TextBlockContent </TextBlock>
                    </TabItem.Header>
                    <Button Height=»22.864″ Name=»button1″ Width=»74.308″>Button</Button>
                </TabItem>

           ( …..  etc )

    …only the little part that sticks up (the «tab», I suppose) is set to the TabItem Background color —  the content area is set to the TabControl Background color.

    Thanks in advance for clarifying this.

Answers

  • To understand the «Scope» of the TabItem, it might be helpful to look into the basic ControlTemplates of the TabControl and TabItem

    <Style  TargetType="{x:Type TabControl}">
      <Setter Property="OverridesDefaultStyle" Value="True" />
      <Setter Property="SnapsToDevicePixels" Value="True" />
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type TabControl}">
            <Grid KeyboardNavigation.TabNavigation="Local">
              <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
              </Grid.RowDefinitions>
              <TabPanel 
                Name="HeaderPanel"
                Grid.Row="0"
                Panel.ZIndex="1" 
                Margin="0,0,4,-1" 
                IsItemsHost="True"
                KeyboardNavigation.TabIndex="1"
                Background="Transparent" />
              <Border 
                Name="Border" 
                Grid.Row="1" 
                Background="{StaticResource WindowBackgroundBrush}" 
                BorderBrush="{StaticResource SolidBorderBrush}" 
                BorderThickness="1" 
                CornerRadius="2" 
                KeyboardNavigation.TabNavigation="Local"
                KeyboardNavigation.DirectionalNavigation="Contained"
                KeyboardNavigation.TabIndex="2" >
                <ContentPresenter 
                  Name="PART_SelectedContentHost"
                  Margin="4"
                  ContentSource="SelectedContent" />
              </Border>
            </Grid>
            <ControlTemplate.Triggers>
              <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}" />
                <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource DisabledBorderBrush}" />
              </Trigger>
            </ControlTemplate.Triggers>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>

    And for the TabItem (http://msdn.microsoft.com/en-us/library/ms752032.aspx)

    <Style TargetType="{x:Type TabItem}">
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type TabItem}">
            <Grid>
              <Border 
                Name="Border"
                Margin="0,0,-4,0" 
                Background="{StaticResource LightBrush}"
                BorderBrush="{StaticResource SolidBorderBrush}" 
                BorderThickness="1,1,1,1" 
                CornerRadius="2,12,0,0" >
                <ContentPresenter x:Name="ContentSite"
                  VerticalAlignment="Center"
                  HorizontalAlignment="Center"
                  ContentSource="Header"
                  Margin="12,2,12,2"
                  RecognizesAccessKey="True"/>
              </Border>
            </Grid>
            <ControlTemplate.Triggers>
              <Trigger Property="IsSelected" Value="True">
                <Setter Property="Panel.ZIndex" Value="100" />
                <Setter TargetName="Border" Property="Background" Value="{StaticResource WindowBackgroundBrush}" />
                <Setter TargetName="Border" Property="BorderThickness" Value="1,1,1,0" />
              </Trigger>
              <Trigger Property="IsEnabled" Value="False">
                <Setter TargetName="Border" Property="Background" Value="{StaticResource DisabledBackgroundBrush}" />
                <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource DisabledBorderBrush}" />
                <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}" />
              </Trigger>
            </ControlTemplate.Triggers>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>

    As you mentioned the TabItem has two parts: The Header, and the Content.

    In the TabControl template the TabPanel is set to ItemsHost, indicating that it is the container for all the TabItems. Note that there is only one ContentPresenter in the TabControl, with it’s ContentSource set to «SelectedContent».

    One final thing to note in the TabItem Template is that the ContentPresenter has it’s ContentSource set to Header.

    This all leads me to believe that our initial assumption is correct. That the TabItem’s header content is displayed inside the TabPanel, and the content panel is bound to the content of the selected TabItem.

    Note: The actual ControlTemplate are more complex than these examples. I’ve found using Expression Blend, and extracting the default template for each control is a good starting point when modifying the templates.

    • Marked as answer by

      Sunday, April 11, 2010 9:17 PM

The TabControl:

In one of the previous articles, we discovered how easy it was to customize the tab headers of the WPF TabControl, for instance to add an image or color
the text. However, if you wish to go beyond that and directly influence how the tab looks, including shape and borders, you need to override the control
template of the TabItem element, and while this is not as straight forward as most other areas of WPF, it’s still manageable.

So, if you would like to get full control of how the tabs of your TabControl looks, check out the next example:

<Window x:Class="WpfTutorialSamples.Misc_controls.StyledTabItemsSample"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="StyledTabItemsSample" Height="150" Width="250">
    <Grid>
        <TabControl Margin="10" BorderThickness="0" Background="LightGray">
            <TabControl.Resources>
                <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="10,2"/>
                                </Grid>
                                <ControlTemplate.Triggers>
                                    <Trigger Property="IsSelected" Value="True">
                                        <Setter TargetName="Panel" Property="Background" Value="LightSkyBlue" />
                                    </Trigger>
                                    <Trigger Property="IsSelected" Value="False">
                                        <Setter TargetName="Panel" Property="Background" Value="White" />
                                    </Trigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </TabControl.Resources>
            <TabItem Header="General">
                <Label Content="Content goes here..." />
            </TabItem>
            <TabItem Header="Security" />
            <TabItem Header="Details" />
        </TabControl>
    </Grid>
</Window>

As you can see, this makes the TabControl looks a bit Windows 8’ish, with no borders and a less subtle color to mark the selected tab and no background for
the unselected tabs. All of this is accomplished by changing the ControlTemplate, using a Style. By adding a ContentPresenter control, we
specify where the content of the TabItem should be placed. We also have a couple of triggers, which controls the background color of the tabs based on the IsSelected property.

In case you want a less subtle look, it’s as easy as changing the template. For instance, you might want a border, but with round corners and a gradient
background — no problem! Check out this next example, where we accomplish just that:

<Window x:Class="WpfTutorialSamples.Misc_controls.StyledTabItemsWithBorderSample"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="StyledTabItemsWithBorderSample" Height="150" Width="250">
    <Grid>
        <TabControl Margin="10" BorderBrush="Gainsboro">
            <TabControl.Resources>
                <Style TargetType="TabItem">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="TabItem">
                                <Border Name="Border" BorderThickness="1,1,1,0" BorderBrush="Gainsboro" CornerRadius="4,4,0,0" Margin="2,0">
                                    <ContentPresenter x:Name="ContentSite"
                                        VerticalAlignment="Center"
                                        HorizontalAlignment="Center"
                                        ContentSource="Header"
                                        Margin="10,2"/>
                                </Border>
                                <ControlTemplate.Triggers>
                                    <Trigger Property="IsSelected" Value="True">
                                        <Setter TargetName="Border" Property="Background" Value="LightSkyBlue" />
                                    </Trigger>
                                    <Trigger Property="IsSelected" Value="False">
                                        <Setter TargetName="Border" Property="Background" Value="GhostWhite" />
                                    </Trigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </TabControl.Resources>
            <TabItem Header="General">
                <Label Content="Content goes here..." />
            </TabItem>
            <TabItem Header="Security" />
            <TabItem Header="Details" />
        </TabControl>
    </Grid>
</Window>

As you can see, I pretty much just added a Border control around the ContentPresenter to achieve this changed look. Hopefully this should demonstrate just
how easy it is to get custom styled tabs and how many possibilities there are in this technique.

This article has been fully translated into the following languages:

  • Chinese

  • Danish

  • French

  • German

  • Italian

  • Polish

  • Portuguese

  • Russian

  • Spanish

Is your preferred language not on the list? Click here to help us translate this article into your language!


Post Views: 3,372

In this post let’s see how we can style our WPF TabContol and its TabItem. WPF TabControl allows us to divide our interface into multiple tabs which our users will find convenient to use rather than a comple WPF Page or a Window. So let’s see how we can design it.

WPF Style TabControl and TabItem:

In your WPF  Window .xaml create a <Window.Resource> tag below and add following styles to it.

MainWindow.xaml: StyleCode-

<Window.Resources>
<Style TargetType="{x:Type TabControl}">
<Setter Property="TabStripPlacement" Value="Top" />
<Setter Property="Margin" Value="0" />
<Setter Property="Padding" Value="0"/>
</Style>

<Style TargetType="TabItem">
<Setter Property="FontSize" Value="10"/>
<Setter Property="BorderBrush" Value="Pink"/>
<Setter Property="BorderThickness" Value="10"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Border x:Name="PART_Border" Background="{TemplateBinding Background}" BorderThickness="1,1,1,0"
BorderBrush="Black" Margin="0,0,0,0" CornerRadius="2,2,0,0" Padding="50,0,50,0">
<ContentPresenter ContentSource="Header" Margin="5" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#fff291"/>
<Setter Property="Foreground" Value="#000"/>
</Trigger>

<Trigger Property="IsSelected" Value="false">
<Setter Property="Background" Value="#013284"/>
<Setter Property="Foreground" Value="#fff"/>

</Trigger>
</ControlTemplate.Triggers>

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

And Create a TabControl and its TabItem like below :

TabControl :

<TabControl>
<TabItem Name="TabItem1" Header="Tab 1" >
<StackPanel Background="White" Height="500" Orientation="Vertical">
<StackPanel Background="#fff291" Height="5"/>
<TextBlock FontSize="25" Padding="25" Foreground="#013284" FontWeight="ExtraBold" >Tab 1</TextBlock>
</StackPanel>
</TabItem>

<TabItem Header="Tab 2" Name="TabItem2" >
<StackPanel Background="White" Height="500" Orientation="Vertical">
<StackPanel Background="#fff291" Height="5"/>
<TextBlock FontSize="25" Padding="25" Foreground="#013284" FontWeight="ExtraBold" >Tab 2</TextBlock>
</StackPanel>
</TabItem>

<TabItem Header="Tab 3" Name="TabItem3" >
<StackPanel Background="White" Height="500" Orientation="Vertical">
<StackPanel Background="#fff291" Height="5"/>
<TextBlock FontSize="25" Padding="25" Foreground="#013284" FontWeight="ExtraBold" >Tab 3</TextBlock>
</StackPanel>
</TabItem>

<TabItem Header="Tab 4" Name="TabItem4" >
<StackPanel Background="White" Height="500" Orientation="Vertical">
<StackPanel Background="#fff291" Height="5"/>
<TextBlock FontSize="25" Padding="25" Foreground="#013284" FontWeight="ExtraBold" >Tab 4</TextBlock>
</StackPanel>
</TabItem>

<TabItem Header="Tab 5" Name="TabItem5">
<StackPanel Background="White" Height="500" Orientation="Vertical">
<StackPanel Background="#fff291" Height="5"/>
<TextBlock FontSize="25" Padding="25" Foreground="#013284" FontWeight="ExtraBold" >Tab 5</TextBlock>
</StackPanel>
</TabItem>
</TabControl>

Now, run your application.

WPF Style TabControl and TabItem 02

Full Page :

MainWindow.xaml:

<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WPF Tabs Styles" Height="350" Width="525" WindowState="Maximized">
<Window.Resources>
<Style TargetType="{x:Type TabControl}">
<Setter Property="TabStripPlacement" Value="Top" />
<Setter Property="Margin" Value="0" />
<Setter Property="Padding" Value="0"/>
</Style>

<Style TargetType="TabItem">
<Setter Property="FontSize" Value="10"/>
<Setter Property="BorderBrush" Value="Pink"/>
<Setter Property="BorderThickness" Value="10"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Border x:Name="PART_Border" Background="{TemplateBinding Background}" BorderThickness="1,1,1,0"
BorderBrush="Black" Margin="0,0,0,0" CornerRadius="2,2,0,0" Padding="50,0,50,0">
<ContentPresenter ContentSource="Header" Margin="5" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#fff291"/>
<Setter Property="Foreground" Value="#000"/>
</Trigger>

<Trigger Property="IsSelected" Value="false">
<Setter Property="Background" Value="#013284"/>
<Setter Property="Foreground" Value="#fff"/>

</Trigger>
</ControlTemplate.Triggers>

</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<StackPanel Orientation="Vertical">

<StackPanel Background="#00173d" Orientation="Vertical">
<TabControl>
<TabItem Name="TabItem1" Header="Tab 1" >
<StackPanel Background="White" Height="500" Orientation="Vertical">
<StackPanel Background="#fff291" Height="5"/>
<TextBlock FontSize="25" Padding="25" Foreground="#013284" FontWeight="ExtraBold" >Tab 1</TextBlock>
</StackPanel>
</TabItem>

<TabItem Header="Tab 2" Name="TabItem2" >
<StackPanel Background="White" Height="500" Orientation="Vertical">
<StackPanel Background="#fff291" Height="5"/>
<TextBlock FontSize="25" Padding="25" Foreground="#013284" FontWeight="ExtraBold" >Tab 2</TextBlock>
</StackPanel>
</TabItem>

<TabItem Header="Tab 3" Name="TabItem3" >
<StackPanel Background="White" Height="500" Orientation="Vertical">
<StackPanel Background="#fff291" Height="5"/>
<TextBlock FontSize="25" Padding="25" Foreground="#013284" FontWeight="ExtraBold" >Tab 3</TextBlock>
</StackPanel>
</TabItem>

<TabItem Header="Tab 4" Name="TabItem4" >
<StackPanel Background="White" Height="500" Orientation="Vertical">
<StackPanel Background="#fff291" Height="5"/>
<TextBlock FontSize="25" Padding="25" Foreground="#013284" FontWeight="ExtraBold" >Tab 4</TextBlock>
</StackPanel>
</TabItem>

<TabItem Header="Tab 5" Name="TabItem5">
<StackPanel Background="White" Height="500" Orientation="Vertical">
<StackPanel Background="#fff291" Height="5"/>
<TextBlock FontSize="25" Padding="25" Foreground="#013284" FontWeight="ExtraBold" >Tab 5</TextBlock>
</StackPanel>
</TabItem>
</TabControl>
</StackPanel>
</StackPanel>
</Window>

Thank You.

Also see :

  • WPF – DataGrid with Buttons and its Clicking method – Get Row Data with WPF DataGrid Buttons
  • WPF – Using DataGrid Row MouseDoubleClick for getting row Data – Example
  • WPF – Designing Material Design Tabs in WPF using Dragablz
  • WPF – Bind ComboBox using MS SQL database
  • WPF Textbox with Rounded Corners
  • WPF Textbox changing Focus Style Background Colors.
  • WPF – Bind DataGrid using SQL Database
  • WPF Button Style with Rounded Corners and Hover Effects
  • WPF Textbox Style – Changing Colors on Focus
  • WPF ComboBox SelectionChanged – SelectedItem Method
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style x:Key="FocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle Margin="2" SnapsToDevicePixels="true"
                                    Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
                                    StrokeThickness="1" StrokeDashArray="1 2"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <SolidColorBrush x:Key="TabItem.Static.Background" Color="White" />
    <SolidColorBrush x:Key="TabItem.Static.Border" Color="#FFF8F8F8"/>
    <SolidColorBrush x:Key="TabItem.MouseOver.Background" Color="#FFF8F8F8"/>
    <SolidColorBrush x:Key="TabItem.MouseOver.Border" Color="#FFF8F8F8"/>
    <SolidColorBrush x:Key="TabItem.Disabled.Background" Color="#F0F0F0"/>
    <SolidColorBrush x:Key="TabItem.Disabled.Border" Color="#FFF8F8F8"/>
    <SolidColorBrush x:Key="TabItem.Selected.Background" Color="#FF007AFF"/>
    <SolidColorBrush x:Key="TabItem.Selected.Border" Color="#FFACACAC"/>
    <Style TargetType="{x:Type TabItem}">
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
        <Setter Property="FontSize" Value="17.4" />
        <Setter Property="Foreground" Value="#FF007AFF"/>
        <Setter Property="Background" Value="{StaticResource TabItem.Static.Background}"/>
        <Setter Property="BorderBrush" Value="{StaticResource TabItem.Static.Border}"/>
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Padding" Value="6,2,6,2"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Grid x:Name="templateRoot" SnapsToDevicePixels="true" Background="#FF007AFF">
                        <Border x:Name="mainBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,1,1,0" Background="{TemplateBinding Background}" Margin="0">
                            <Border x:Name="innerBorder" BorderBrush="{StaticResource TabItem.Selected.Border}" BorderThickness="1,1,1,0" Background="{DynamicResource TabItem.Static.Background}" Margin="-1" Opacity="0"/>
                        </Border>
                        <ContentPresenter x:Name="contentPresenter" ContentSource="Header"
                                          Focusable="
                                          HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" Margin="{TemplateBinding Padding}"
                                          RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                          VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Background}"/>
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Border}"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,1"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Background}"/>
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Border}"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,1"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Background}"/>
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Border}"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,1"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Top"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Background}"/>
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.MouseOver.Border}"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,0"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,0"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
                            <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Background}"/>
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Border}"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,1"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
                            <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Background}"/>
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Border}"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,1"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
                            <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Background}"/>
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Border}"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,1"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Top"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
                            <Setter Property="Background" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Background}"/>
                            <Setter Property="BorderBrush" TargetName="mainBorder" Value="{StaticResource TabItem.Disabled.Border}"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,0"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,0"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,1"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Panel.ZIndex" Value="1"/>
                            <Setter Property="Margin" Value="-2,-2,0,-2"/>
                            <Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,1"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,1"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Panel.ZIndex" Value="1"/>
                            <Setter Property="Margin" Value="-2,0,-2,-2"/>
                            <Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
                            <Setter Property="Opacity" TargetName="mainBorder" Value="1"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,1"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,1"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Panel.ZIndex" Value="1"/>
                            <Setter Property="Margin" Value="0,-2,-2,-2"/>
                            <Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,1"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="0,1,1,1"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Top"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,0"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,0"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="true"/>
                                <Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Top"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Panel.ZIndex" Value="1"/>
                            <Setter Property="Margin" Value="-2,-2,-2,0"/>
                            <Setter Property="Opacity" TargetName="innerBorder" Value="1"/>
                            <Setter Property="BorderThickness" TargetName="innerBorder" Value="1,1,1,0"/>
                            <Setter Property="BorderThickness" TargetName="mainBorder" Value="1,1,1,0"/>
                        </MultiDataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>

Понравилась статья? Поделить с друзьями:
  • T1m6 error 20
  • T12 multicontrol ошибка
  • T1000s контроллер горит error
  • Systemsettingsbroker exe ошибка приложения
  • Systemd журнал ошибок