<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
                    xmlns:Converters="clr-namespace:Vulnerator.View.Converter"
                    xmlns:IconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
                    xmlns:local="clr-namespace:Vulnerator.View.Styles"
                    xmlns:po="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
                    xmlns:vh="clr-namespace:Vulnerator.View.ViewHelper"
                    xmlns:vm="clr-namespace:Vulnerator.ViewModel">

    <Style x:Key="CustomMetroTabItem"
           TargetType="TabItem">
        <Setter Property="Background" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=Background, Mode=OneWay}" />
        <Setter Property="BorderBrush" Value="{DynamicResource AccentColorBrush}" />
        <Setter Property="BorderThickness" Value="0" />
        <!--  special property for header font size  -->
        <Setter Property="Controls:ControlsHelper.HeaderFontSize" Value="{DynamicResource TabItemFontSize}" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="MinHeight" Value="5" />
        <Setter Property="MinWidth" Value="5" />
        <Setter Property="Padding" Value="6,2,6,2" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TabItem">
                    <Border x:Name="Border"
                            HorizontalAlignment="Stretch"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <Border Padding="{TemplateBinding Padding}"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                UseLayoutRounding="True">
                            <Grid x:Name="InnerGrid"
                                  Width="Auto"
                                  Height="Auto"
                                  HorizontalAlignment="Center"
                                  VerticalAlignment="Center">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition x:Name="PART_ContentLeftCol"
                                                      Width="Auto" />
                                    <ColumnDefinition x:Name="PART_ContentRightCol"
                                                      Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition x:Name="PART_ContentTopRow"
                                                   Height="Auto" />
                                    <RowDefinition x:Name="PART_ContentBottomRow"
                                                   Height="Auto" />
                                </Grid.RowDefinitions>
                                <Controls:ContentControlEx x:Name="ContentSite"
                                                           Grid.Row="0"
                                                           Grid.Column="0"
                                                           Content="{TemplateBinding Header}"
                                                           ContentCharacterCasing="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ContentCharacterCasing)}"
                                                           ContentStringFormat="{TemplateBinding HeaderStringFormat}"
                                                           ContentTemplate="{TemplateBinding HeaderTemplate}"
                                                           ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
                                                           FontFamily="Segoe UI Light"
                                                           FontSize="{TemplateBinding Controls:ControlsHelper.HeaderFontSize}"
                                                           FontStretch="{TemplateBinding Controls:ControlsHelper.HeaderFontStretch}"
                                                           FontStyle="{TemplateBinding FontStyle}"
                                                           FontWeight="{TemplateBinding Controls:ControlsHelper.HeaderFontWeight}"
                                                           Foreground="{TemplateBinding Foreground}"
                                                           RecognizesAccessKey="True"
                                                           SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                                           UseLayoutRounding="False" />
                                <Controls:Underline x:Name="Underline"
                                                    Grid.Row="1"
                                                    Grid.Column="0"
                                                    HorizontalAlignment="Stretch"
                                                    VerticalAlignment="Stretch"
                                                    Background="{TemplateBinding Background}"
                                                    BorderBrush="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=(Controls:TabControlHelper.UnderlineBrush), Mode=OneWay}"
                                                    LineExtent="3"
                                                    LineThickness="2"
                                                    Placement="Bottom"
                                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                            </Grid>
                        </Border>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="TabStripPlacement" Value="Left">
                            <Setter TargetName="ContentSite" Property="Grid.Column" Value="1" />
                            <Setter TargetName="ContentSite" Property="Grid.Row" Value="0" />
                            <Setter TargetName="PART_ContentBottomRow" Property="Height" Value="Auto" />
                            <Setter TargetName="PART_ContentLeftCol" Property="Width" Value="Auto" />
                            <Setter TargetName="PART_ContentRightCol" Property="Width" Value="*" />
                            <Setter TargetName="PART_ContentTopRow" Property="Height" Value="*" />
                            <Setter TargetName="Underline" Property="Grid.Column" Value="0" />
                            <Setter TargetName="Underline" Property="Grid.Row" Value="0" />
                            <Setter TargetName="Underline" Property="Height" Value="{Binding ElementName=InnerGrid, Path=ActualHeight}" />
                            <Setter TargetName="Underline" Property="Placement" Value="Left" />
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Top">
                            <Setter TargetName="ContentSite" Property="Grid.Column" Value="0" />
                            <Setter TargetName="ContentSite" Property="Grid.Row" Value="0" />
                            <Setter TargetName="PART_ContentBottomRow" Property="Height" Value="Auto" />
                            <Setter TargetName="PART_ContentLeftCol" Property="Width" Value="*" />
                            <Setter TargetName="PART_ContentRightCol" Property="Width" Value="Auto" />
                            <Setter TargetName="PART_ContentTopRow" Property="Height" Value="*" />
                            <Setter TargetName="Underline" Property="Grid.Column" Value="0" />
                            <Setter TargetName="Underline" Property="Grid.Row" Value="1" />
                            <Setter TargetName="Underline" Property="Placement" Value="Bottom" />
                            <Setter TargetName="Underline" Property="Width" Value="{Binding ElementName=InnerGrid, Path=ActualWidth}" />
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Right">
                            <Setter TargetName="ContentSite" Property="Grid.Column" Value="1" />
                            <Setter TargetName="ContentSite" Property="Grid.Row" Value="0" />
                            <Setter TargetName="PART_ContentBottomRow" Property="Height" Value="Auto" />
                            <Setter TargetName="PART_ContentLeftCol" Property="Width" Value="Auto" />
                            <Setter TargetName="PART_ContentRightCol" Property="Width" Value="*" />
                            <Setter TargetName="PART_ContentTopRow" Property="Height" Value="*" />
                            <Setter TargetName="Underline" Property="Grid.Column" Value="0" />
                            <Setter TargetName="Underline" Property="Grid.Row" Value="0" />
                            <Setter TargetName="Underline" Property="Height" Value="{Binding ElementName=InnerGrid, Path=ActualHeight}" />
                            <Setter TargetName="Underline" Property="Placement" Value="Left" />
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Bottom">
                            <Setter TargetName="ContentSite" Property="Grid.Column" Value="0" />
                            <Setter TargetName="ContentSite" Property="Grid.Row" Value="1" />
                            <Setter TargetName="PART_ContentBottomRow" Property="Height" Value="*" />
                            <Setter TargetName="PART_ContentLeftCol" Property="Width" Value="*" />
                            <Setter TargetName="PART_ContentRightCol" Property="Width" Value="Auto" />
                            <Setter TargetName="PART_ContentTopRow" Property="Height" Value="Auto" />
                            <Setter TargetName="Underline" Property="Grid.Column" Value="0" />
                            <Setter TargetName="Underline" Property="Grid.Row" Value="0" />
                            <Setter TargetName="Underline" Property="Placement" Value="Top" />
                            <Setter TargetName="Underline" Property="Width" Value="{Binding ElementName=InnerGrid, Path=ActualWidth}" />
                        </Trigger>

                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=(Controls:TabControlHelper.Underlined)}"
                                     Value="None">
                            <Setter TargetName="Underline" Property="Visibility" Value="Collapsed" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=(Controls:TabControlHelper.Underlined)}"
                                     Value="SelectedTabItem">
                            <Setter TargetName="Underline" Property="LineThickness" Value="0" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=(Controls:TabControlHelper.Underlined)}"
                                     Value="TabPanel">
                            <Setter TargetName="Underline" Property="LineExtent" Value="4" />
                            <Setter TargetName="Underline" Property="LineThickness" Value="1" />
                        </DataTrigger>

                        <Trigger Property="IsSelected" Value="true">
                            <Setter TargetName="ContentSite" Property="TextElement.Foreground" Value="{DynamicResource AccentColorBrush}" />
                            <Setter TargetName="Underline" Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=(Controls:TabControlHelper.UnderlineSelectedBrush), Mode=OneWay}" />
                        </Trigger>
                        <Trigger Property="IsSelected" Value="false">
                            <Setter TargetName="ContentSite" Property="TextElement.Foreground" Value="{DynamicResource GrayNormalBrush}" />
                        </Trigger>

                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=(Controls:TabControlHelper.Underlined)}" Value="TabPanel" />
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="True" />
                            </MultiDataTrigger.Conditions>
                            <Setter TargetName="Underline" Property="LineThickness" Value="3" />
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=(Controls:TabControlHelper.Underlined)}" Value="SelectedTabItem" />
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="True" />
                            </MultiDataTrigger.Conditions>
                            <Setter TargetName="Underline" Property="LineThickness" Value="2" />
                        </MultiDataTrigger>

                        <Trigger SourceName="Border" Property="IsMouseOver" Value="True">
                            <Setter TargetName="ContentSite" Property="TextElement.Foreground" Value="{DynamicResource GrayHoverBrush}" />
                            <Setter TargetName="Underline" Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=(Controls:TabControlHelper.UnderlineMouseOverBrush), Mode=OneWay}" />
                        </Trigger>

                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=(Controls:TabControlHelper.Underlined)}" Value="TabPanel" />
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="False" />
                                <Condition Binding="{Binding ElementName=Border, Path=IsMouseOver}" Value="True" />
                            </MultiDataTrigger.Conditions>
                            <Setter TargetName="Underline" Property="LineThickness" Value="2" />
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=(Controls:TabControlHelper.Underlined)}" Value="SelectedTabItem" />
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="False" />
                                <Condition Binding="{Binding ElementName=Border, Path=IsMouseOver}" Value="True" />
                            </MultiDataTrigger.Conditions>
                            <Setter TargetName="Underline" Property="LineThickness" Value="2" />
                        </MultiDataTrigger>

                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition SourceName="Border" Property="IsMouseOver" Value="True" />
                                <Condition Property="IsSelected" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="ContentSite" Property="TextElement.Foreground" Value="{DynamicResource HighlightBrush}" />
                            <Setter TargetName="Underline" Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=(Controls:TabControlHelper.UnderlineMouseOverSelectedBrush), Mode=OneWay}" />
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
    </Style>

    <Style x:Key="CustomVerticalMetroTabItem"
           TargetType="TabItem">
        <Setter Property="Background" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=Background, Mode=OneWay}" />
        <Setter Property="BorderBrush" Value="{DynamicResource AccentColorBrush}" />
        <Setter Property="BorderThickness" Value="0" />
        <!--  special property for header font size  -->
        <Setter Property="Controls:ControlsHelper.HeaderFontSize" Value="{DynamicResource TabItemFontSize}" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="MinHeight" Value="5" />
        <Setter Property="MinWidth" Value="5" />
        <Setter Property="Padding" Value="6,2,6,2" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TabItem">
                    <Border x:Name="Border"
                            HorizontalAlignment="Stretch"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <Border Padding="{TemplateBinding Padding}"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                UseLayoutRounding="True">
                            <Grid x:Name="InnerGrid"
                                  HorizontalAlignment="Stretch"
                                  VerticalAlignment="Center">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition x:Name="PART_ContentLeftCol"
                                                      Width="Auto" />
                                    <ColumnDefinition x:Name="PART_ContentRightCol"
                                                      Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition x:Name="PART_ContentTopRow"
                                                   Height="Auto" />
                                    <RowDefinition x:Name="PART_ContentBottomRow"
                                                   Height="Auto" />
                                </Grid.RowDefinitions>
                                <Controls:ContentControlEx x:Name="ContentSite"
                                                           Grid.Row="0"
                                                           Grid.Column="0"
                                                           Content="{TemplateBinding Header}"
                                                           ContentCharacterCasing="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ContentCharacterCasing)}"
                                                           ContentStringFormat="{TemplateBinding HeaderStringFormat}"
                                                           ContentTemplate="{TemplateBinding HeaderTemplate}"
                                                           ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
                                                           FontFamily="Segoe UI Light"
                                                           FontSize="{TemplateBinding Controls:ControlsHelper.HeaderFontSize}"
                                                           FontStretch="{TemplateBinding Controls:ControlsHelper.HeaderFontStretch}"
                                                           FontStyle="{TemplateBinding FontStyle}"
                                                           FontWeight="{TemplateBinding Controls:ControlsHelper.HeaderFontWeight}"
                                                           Foreground="{TemplateBinding Foreground}"
                                                           RecognizesAccessKey="True"
                                                           SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                                           UseLayoutRounding="False" />
                                <Controls:Underline x:Name="Underline"
                                                    Grid.Row="1"
                                                    Grid.Column="0"
                                                    HorizontalAlignment="Stretch"
                                                    VerticalAlignment="Stretch"
                                                    Background="{TemplateBinding Background}"
                                                    BorderBrush="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=(Controls:TabControlHelper.UnderlineBrush), Mode=OneWay}"
                                                    LineExtent="3"
                                                    LineThickness="2"
                                                    Placement="Bottom"
                                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                            </Grid>
                        </Border>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="TabStripPlacement" Value="Left">
                            <Setter TargetName="ContentSite" Property="Grid.Column" Value="1" />
                            <Setter TargetName="ContentSite" Property="Grid.Row" Value="0" />
                            <Setter TargetName="PART_ContentBottomRow" Property="Height" Value="Auto" />
                            <Setter TargetName="PART_ContentLeftCol" Property="Width" Value="Auto" />
                            <Setter TargetName="PART_ContentRightCol" Property="Width" Value="*" />
                            <Setter TargetName="PART_ContentTopRow" Property="Height" Value="*" />
                            <Setter TargetName="Underline" Property="Grid.Column" Value="0" />
                            <Setter TargetName="Underline" Property="Grid.Row" Value="0" />
                            <Setter TargetName="Underline" Property="Height" Value="{Binding ElementName=InnerGrid, Path=ActualHeight}" />
                            <Setter TargetName="Underline" Property="Placement" Value="Left" />
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Top">
                            <Setter TargetName="ContentSite" Property="Grid.Column" Value="0" />
                            <Setter TargetName="ContentSite" Property="Grid.Row" Value="0" />
                            <Setter TargetName="PART_ContentBottomRow" Property="Height" Value="Auto" />
                            <Setter TargetName="PART_ContentLeftCol" Property="Width" Value="*" />
                            <Setter TargetName="PART_ContentRightCol" Property="Width" Value="Auto" />
                            <Setter TargetName="PART_ContentTopRow" Property="Height" Value="*" />
                            <Setter TargetName="Underline" Property="Grid.Column" Value="0" />
                            <Setter TargetName="Underline" Property="Grid.Row" Value="1" />
                            <Setter TargetName="Underline" Property="Placement" Value="Bottom" />
                            <Setter TargetName="Underline" Property="Width" Value="{Binding ElementName=InnerGrid, Path=ActualWidth}" />
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Right">
                            <Setter TargetName="ContentSite" Property="Grid.Column" Value="1" />
                            <Setter TargetName="ContentSite" Property="Grid.Row" Value="0" />
                            <Setter TargetName="PART_ContentBottomRow" Property="Height" Value="Auto" />
                            <Setter TargetName="PART_ContentLeftCol" Property="Width" Value="Auto" />
                            <Setter TargetName="PART_ContentRightCol" Property="Width" Value="*" />
                            <Setter TargetName="PART_ContentTopRow" Property="Height" Value="*" />
                            <Setter TargetName="Underline" Property="Grid.Column" Value="0" />
                            <Setter TargetName="Underline" Property="Grid.Row" Value="0" />
                            <Setter TargetName="Underline" Property="Height" Value="{Binding ElementName=InnerGrid, Path=ActualHeight}" />
                            <Setter TargetName="Underline" Property="Placement" Value="Left" />
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Bottom">
                            <Setter TargetName="ContentSite" Property="Grid.Column" Value="0" />
                            <Setter TargetName="ContentSite" Property="Grid.Row" Value="1" />
                            <Setter TargetName="PART_ContentBottomRow" Property="Height" Value="*" />
                            <Setter TargetName="PART_ContentLeftCol" Property="Width" Value="*" />
                            <Setter TargetName="PART_ContentRightCol" Property="Width" Value="Auto" />
                            <Setter TargetName="PART_ContentTopRow" Property="Height" Value="Auto" />
                            <Setter TargetName="Underline" Property="Grid.Column" Value="0" />
                            <Setter TargetName="Underline" Property="Grid.Row" Value="0" />
                            <Setter TargetName="Underline" Property="Placement" Value="Top" />
                            <Setter TargetName="Underline" Property="Width" Value="{Binding ElementName=InnerGrid, Path=ActualWidth}" />
                        </Trigger>

                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=(Controls:TabControlHelper.Underlined)}"
                                     Value="None">
                            <Setter TargetName="Underline" Property="Visibility" Value="Collapsed" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=(Controls:TabControlHelper.Underlined)}"
                                     Value="SelectedTabItem">
                            <Setter TargetName="Underline" Property="LineThickness" Value="0" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=(Controls:TabControlHelper.Underlined)}"
                                     Value="TabPanel">
                            <Setter TargetName="Underline" Property="LineExtent" Value="4" />
                            <Setter TargetName="Underline" Property="LineThickness" Value="1" />
                        </DataTrigger>

                        <Trigger Property="IsSelected" Value="true">
                            <Setter TargetName="ContentSite" Property="TextElement.Foreground" Value="{DynamicResource AccentColorBrush}" />
                            <Setter TargetName="Underline" Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=(Controls:TabControlHelper.UnderlineSelectedBrush), Mode=OneWay}" />
                        </Trigger>
                        <Trigger Property="IsSelected" Value="false">
                            <Setter TargetName="ContentSite" Property="TextElement.Foreground" Value="{DynamicResource GrayNormalBrush}" />
                        </Trigger>

                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=(Controls:TabControlHelper.Underlined)}" Value="TabPanel" />
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="True" />
                            </MultiDataTrigger.Conditions>
                            <Setter TargetName="Underline" Property="LineThickness" Value="3" />
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=(Controls:TabControlHelper.Underlined)}" Value="SelectedTabItem" />
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="True" />
                            </MultiDataTrigger.Conditions>
                            <Setter TargetName="Underline" Property="LineThickness" Value="2" />
                        </MultiDataTrigger>

                        <Trigger SourceName="Border" Property="IsMouseOver" Value="True">
                            <Setter TargetName="ContentSite" Property="TextElement.Foreground" Value="{DynamicResource GrayHoverBrush}" />
                            <Setter TargetName="Underline" Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=(Controls:TabControlHelper.UnderlineMouseOverBrush), Mode=OneWay}" />
                        </Trigger>

                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=(Controls:TabControlHelper.Underlined)}" Value="TabPanel" />
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="False" />
                                <Condition Binding="{Binding ElementName=Border, Path=IsMouseOver}" Value="True" />
                            </MultiDataTrigger.Conditions>
                            <Setter TargetName="Underline" Property="LineThickness" Value="2" />
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=(Controls:TabControlHelper.Underlined)}" Value="SelectedTabItem" />
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="False" />
                                <Condition Binding="{Binding ElementName=Border, Path=IsMouseOver}" Value="True" />
                            </MultiDataTrigger.Conditions>
                            <Setter TargetName="Underline" Property="LineThickness" Value="2" />
                        </MultiDataTrigger>

                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition SourceName="Border" Property="IsMouseOver" Value="True" />
                                <Condition Property="IsSelected" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="ContentSite" Property="TextElement.Foreground" Value="{DynamicResource HighlightBrush}" />
                            <Setter TargetName="Underline" Property="BorderBrush" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=(Controls:TabControlHelper.UnderlineMouseOverSelectedBrush), Mode=OneWay}" />
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
    </Style>

</ResourceDictionary>