<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:bpa="clr-namespace:BPA.UIControl">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/BPA.UIControl;component/Themes/ScrollViewer.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="RubyerTabItem" TargetType="{x:Type TabItem}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
        <Setter Property="Foreground" Value="{Binding Path=(bpa:HeaderHelper.Foreground), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="Padding" Value="{Binding Path=(bpa:HeaderHelper.Padding), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="HorizontalAlignment" Value="{Binding Path=(bpa:HeaderHelper.HorizontalAlignment), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="VerticalAlignment" Value="{Binding Path=(bpa:HeaderHelper.VerticalAlignment), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="FontSize" Value="{Binding Path=(bpa:HeaderHelper.FontSize), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="FontWeight" Value="{Binding Path=(bpa:HeaderHelper.FontWeight), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="FontFamily" Value="{Binding Path=(bpa:HeaderHelper.FontFamily), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="bpa:TabControlHelper.IsClearable" Value="{Binding Path=(bpa:TabControlHelper.IsClearable), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="bpa:ControlHelper.FocusedForegroundBrush" Value="{Binding Path=(bpa:ControlHelper.FocusedForegroundBrush), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="bpa:ControlHelper.CornerRadius" Value="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="bpa:ControlHelper.MaskOpacity" Value="{Binding Path=(bpa:ControlHelper.MaskOpacity), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Grid x:Name="templateRoot" SnapsToDevicePixels="True">
                        <bpa:ControlMask x:Name="mask"
                                         Background="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                         CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                         IsActive="{TemplateBinding IsSelected}"
                                         MaskOpacity="{Binding Path=(bpa:ControlHelper.MaskOpacity), RelativeSource={RelativeSource Mode=TemplatedParent}}" />

                        <DockPanel x:Name="contentPanel"
                                   Margin="{TemplateBinding Padding}"
                                   HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                                   VerticalAlignment="{TemplateBinding VerticalAlignment}">
                            <Button x:Name="clearButton"
                                    Style="{StaticResource TextButton}"
                                    Margin="5 0 0 0"
                                    Padding="2"
                                    bpa:ButtonHelper.Shape="Circle"
                                    bpa:ControlHelper.FocusedBrush="{DynamicResource MaskDark}"
                                    DockPanel.Dock="Right"
                                    Foreground="{TemplateBinding Foreground}"
                                    Visibility="Hidden">
                                <bpa:Icon Type="CloseLine" />
                            </Button>

                            <ContentPresenter x:Name="contentPresenter"
                                              ContentSource="Header"
                                              Focusable="False"
                                              RecognizesAccessKey="True"
                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </DockPanel>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left">
                            <Setter Property="HorizontalAlignment" Value="Stretch" />
                            <Setter TargetName="contentPresenter" Property="HorizontalAlignment" Value="Center" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right">
                            <Setter Property="HorizontalAlignment" Value="Stretch" />
                            <Setter TargetName="contentPresenter" Property="HorizontalAlignment" Value="Center" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Path=(bpa:TabControlHelper.IsClearable), RelativeSource={RelativeSource Self}}" Value="False">
                            <Setter TargetName="clearButton" Property="Visibility" Value="Collapsed" />
                        </DataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="True" />
                                <Condition Binding="{Binding Path=(bpa:TabControlHelper.IsClearable), RelativeSource={RelativeSource Self}}" Value="True" />
                            </MultiDataTrigger.Conditions>
                            <Setter TargetName="clearButton" Property="Visibility" Value="Visible" />
                        </MultiDataTrigger>
                        <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True">
                            <Setter Property="TextBlock.Foreground" Value="{Binding Path=(bpa:ControlHelper.FocusedForegroundBrush), RelativeSource={RelativeSource Mode=Self}}" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="False">
                            <Setter TargetName="templateRoot" Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="RubyerTabControl" TargetType="{x:Type TabControl}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource Self}}" />
        <Setter Property="BorderThickness" Value="0 2.5 0 0" />
        <Setter Property="Foreground" Value="{DynamicResource DefaultForeground}" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="ItemContainerStyle" Value="{StaticResource RubyerTabItem}" />
        <Setter Property="bpa:ControlHelper.CornerRadius" Value="{DynamicResource TopControlCornerRadius}" />
        <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{DynamicResource Primary}" />
        <Setter Property="bpa:ControlHelper.FocusedForegroundBrush" Value="{DynamicResource WhiteForeground}" />
        <Setter Property="bpa:ControlHelper.FocusBorderBrush" Value="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource Self}}" />
        <Setter Property="bpa:ControlHelper.MaskOpacity" Value="1" />
        <Setter Property="bpa:TabControlHelper.IsClearable" Value="False" />
        <Setter Property="bpa:HeaderHelper.HorizontalAlignment" Value="Center" />
        <Setter Property="bpa:HeaderHelper.VerticalAlignment" Value="Center" />
        <Setter Property="bpa:HeaderHelper.Padding" Value="10 5" />
        <Setter Property="bpa:HeaderHelper.Margin" Value="0" />
        <Setter Property="bpa:HeaderHelper.Foreground" Value="{DynamicResource DefaultForeground}" />
        <Setter Property="bpa:HeaderHelper.Background" Value="Transparent" />
        <Setter Property="bpa:HeaderHelper.FontSize" Value="{Binding FontSize, RelativeSource={RelativeSource Self}}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">
                    <Grid x:Name="templateRoot"
                          ClipToBounds="True"
                          KeyboardNavigation.TabNavigation="Local"
                          SnapsToDevicePixels="True">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition x:Name="ColumnDefinition0" />
                            <ColumnDefinition x:Name="ColumnDefinition1" Width="0" />
                            <ColumnDefinition x:Name="ColumnDefinition2" Width="0" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition x:Name="RowDefinition0" Height="Auto" />
                            <RowDefinition x:Name="RowDefinition1" Height="0" />
                            <RowDefinition x:Name="RowDefinition2" Height="*" />
                        </Grid.RowDefinitions>

                        <ScrollViewer x:Name="headerPanel"
                                      Style="{StaticResource OnlyArrowScrollViewer}"
                                      Grid.Row="0"
                                      Grid.Column="0"
                                      Panel.ZIndex="1"
                                      bpa:ScrollViewerHelper.HorizontalDelta="150"
                                      bpa:ScrollViewerHelper.VerticalDelta="75"
                                      Background="{Binding Path=(bpa:HeaderHelper.Background), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                      Foreground="{Binding Path=(bpa:HeaderHelper.Foreground), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                      HorizontalScrollBarVisibility="Auto"
                                      VerticalScrollBarVisibility="Auto">
                            <StackPanel x:Name="headerStackPanel" Orientation="Horizontal">
                                <TabPanel IsItemsHost="True" KeyboardNavigation.TabIndex="1" />
                                <Button x:Name="PART_AddButton"
                                        Style="{StaticResource TextButton}"
                                        Margin="5 0 0 0"
                                        bpa:ButtonHelper.Shape="Circle"
                                        bpa:ControlHelper.FocusedBrush="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                        Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType=ScrollViewer}}"
                                        Visibility="{Binding Path=(bpa:TabControlHelper.IsShowAddButton), Converter={StaticResource BooleanToVisibleConverter}, RelativeSource={RelativeSource Mode=TemplatedParent}}">
                                    <bpa:Icon Type="AddLine" />
                                </Button>
                            </StackPanel>
                        </ScrollViewer>

                        <Border x:Name="contentPanel"
                                Grid.Row="2"
                                Grid.Column="0"
                                Margin="0 -2.5 0 0"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                KeyboardNavigation.DirectionalNavigation="Contained"
                                KeyboardNavigation.TabIndex="2"
                                KeyboardNavigation.TabNavigation="Local">

                            <ContentPresenter x:Name="PART_SelectedContentHost"
                                              Margin="{TemplateBinding Padding}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                              ContentSource="SelectedContent"
                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="TabStripPlacement" Value="Bottom">
                            <Setter TargetName="RowDefinition0" Property="Height" Value="*" />
                            <Setter TargetName="RowDefinition2" Property="Height" Value="Auto" />
                            <Setter TargetName="contentPanel" Property="BorderThickness" Value="0 0 0 2.5" />
                            <Setter TargetName="contentPanel" Property="Margin" Value="0 0 0 -2.5" />
                            <Setter TargetName="contentPanel" Property="Grid.Row" Value="0" />
                            <Setter TargetName="headerPanel" Property="Grid.Row" Value="2" />
                            <Setter Property="bpa:ControlHelper.CornerRadius" Value="{DynamicResource BottomControlCornerRadius}" />
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Left">
                            <Setter TargetName="ColumnDefinition0" Property="Width" Value="Auto" />
                            <Setter TargetName="ColumnDefinition1" Property="Width" Value="0" />
                            <Setter TargetName="ColumnDefinition2" Property="Width" Value="*" />
                            <Setter TargetName="RowDefinition0" Property="Height" Value="*" />
                            <Setter TargetName="RowDefinition1" Property="Height" Value="0" />
                            <Setter TargetName="RowDefinition2" Property="Height" Value="0" />
                            <Setter TargetName="contentPanel" Property="Grid.Column" Value="2" />
                            <Setter TargetName="contentPanel" Property="Grid.Row" Value="0" />
                            <Setter TargetName="contentPanel" Property="BorderThickness" Value="2.5 0 0 0" />
                            <Setter TargetName="contentPanel" Property="Margin" Value="-2.5 0 0 0" />
                            <Setter TargetName="headerPanel" Property="Grid.Column" Value="0" />
                            <Setter TargetName="headerPanel" Property="Grid.Row" Value="0" />
                            <Setter Property="bpa:ControlHelper.CornerRadius" Value="{DynamicResource LeftControlCornerRadius}" />
                            <Setter TargetName="headerStackPanel" Property="Orientation" Value="Vertical" />
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Right">
                            <Setter TargetName="ColumnDefinition0" Property="Width" Value="*" />
                            <Setter TargetName="ColumnDefinition1" Property="Width" Value="0" />
                            <Setter TargetName="ColumnDefinition2" Property="Width" Value="Auto" />
                            <Setter TargetName="RowDefinition0" Property="Height" Value="*" />
                            <Setter TargetName="RowDefinition1" Property="Height" Value="0" />
                            <Setter TargetName="RowDefinition2" Property="Height" Value="0" />
                            <Setter TargetName="contentPanel" Property="Grid.Column" Value="0" />
                            <Setter TargetName="contentPanel" Property="Grid.Row" Value="0" />
                            <Setter TargetName="contentPanel" Property="BorderThickness" Value="0 0 2.5 0" />
                            <Setter TargetName="contentPanel" Property="Margin" Value="0 0 -2.5 0" />
                            <Setter TargetName="headerPanel" Property="Grid.Column" Value="2" />
                            <Setter TargetName="headerPanel" Property="Grid.Row" Value="0" />
                            <Setter Property="bpa:ControlHelper.CornerRadius" Value="{DynamicResource RightControlCornerRadius}" />
                            <Setter TargetName="headerStackPanel" Property="Orientation" Value="Vertical" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="templateRoot" Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="LineTabItem" TargetType="{x:Type TabItem}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
        <Setter Property="Foreground" Value="{Binding Path=(bpa:HeaderHelper.Foreground), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="Padding" Value="{Binding Path=(bpa:HeaderHelper.Padding), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="HorizontalAlignment" Value="{Binding Path=(bpa:HeaderHelper.HorizontalAlignment), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="VerticalAlignment" Value="{Binding Path=(bpa:HeaderHelper.VerticalAlignment), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="bpa:TabControlHelper.IsClearable" Value="{Binding Path=(bpa:TabControlHelper.IsClearable), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="FontSize" Value="{Binding Path=(bpa:HeaderHelper.FontSize), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="FontWeight" Value="{Binding Path=(bpa:HeaderHelper.FontWeight), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="FontFamily" Value="{Binding Path=(bpa:HeaderHelper.FontFamily), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Grid x:Name="templateRoot" SnapsToDevicePixels="True">
                        <Border x:Name="mainBorder"
                                Margin="0"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="0"
                                SnapsToDevicePixels="True" />

                        <DockPanel>
                            <bpa:Transition x:Name="lineTransirion"
                                            DockPanel.Dock="Bottom"
                                            IsShow="{TemplateBinding IsSelected}"
                                            Type="CollapseLeft">
                                <Rectangle x:Name="line"
                                           Width="{Binding ActualWidth, ElementName=templateRoot}"
                                           Height="2.5"
                                           Fill="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
                            </bpa:Transition>

                            <DockPanel Margin="{TemplateBinding Padding}"
                                       HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                                       VerticalAlignment="{TemplateBinding VerticalAlignment}">
                                <Button x:Name="clearButton"
                                        Style="{StaticResource TextButton}"
                                        Margin="5 0 0 0"
                                        Padding="2"
                                        bpa:ButtonHelper.Shape="Circle"
                                        DockPanel.Dock="Right"
                                        Foreground="{TemplateBinding Foreground}"
                                        Visibility="Hidden">
                                    <bpa:Icon Type="CloseLine" />
                                </Button>

                                <ContentPresenter x:Name="contentPresenter"
                                                  ContentSource="Header"
                                                  Focusable="False"
                                                  RecognizesAccessKey="True"
                                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                            </DockPanel>
                        </DockPanel>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left">
                            <Setter Property="HorizontalAlignment" Value="Stretch" />
                            <Setter TargetName="contentPresenter" Property="HorizontalAlignment" Value="Center" />
                            <Setter TargetName="line" Property="Height" Value="{Binding ActualHeight, ElementName=templateRoot}" />
                            <Setter TargetName="line" Property="Width" Value="2.5" />
                            <Setter TargetName="lineTransirion" Property="DockPanel.Dock" Value="Right" />
                            <Setter TargetName="lineTransirion" Property="Type" Value="CollapseDown" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right">
                            <Setter Property="HorizontalAlignment" Value="Stretch" />
                            <Setter TargetName="contentPresenter" Property="HorizontalAlignment" Value="Center" />
                            <Setter TargetName="line" Property="Height" Value="{Binding ActualHeight, ElementName=templateRoot}" />
                            <Setter TargetName="line" Property="Width" Value="2.5" />
                            <Setter TargetName="lineTransirion" Property="DockPanel.Dock" Value="Left" />
                            <Setter TargetName="lineTransirion" Property="Type" Value="CollapseDown" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Bottom">
                            <Setter TargetName="lineTransirion" Property="DockPanel.Dock" Value="Top" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Path=(bpa:TabControlHelper.IsClearable), RelativeSource={RelativeSource Self}}" Value="False">
                            <Setter TargetName="clearButton" Property="Visibility" Value="Collapsed" />
                        </DataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="True" />
                                <Condition Binding="{Binding Path=(bpa:TabControlHelper.IsClearable), RelativeSource={RelativeSource Self}}" Value="True" />
                            </MultiDataTrigger.Conditions>
                            <Setter TargetName="clearButton" Property="Visibility" Value="Visible" />
                        </MultiDataTrigger>
                        <DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="True">
                            <Setter Property="TextBlock.Foreground" Value="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource Mode=Self}}" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True">
                            <Setter Property="TextBlock.Foreground" Value="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource Mode=Self}}" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="False">
                            <Setter TargetName="templateRoot" Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="LineTabControl"
           BasedOn="{StaticResource RubyerTabControl}"
           TargetType="{x:Type TabControl}">
        <Setter Property="BorderBrush" Value="{DynamicResource BorderLighter}" />
        <Setter Property="bpa:ControlHelper.FocusedForegroundBrush" Value="{DynamicResource Primary}" />
        <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{Binding Path=(bpa:ControlHelper.FocusedForegroundBrush), RelativeSource={RelativeSource Self}}" />
        <Setter Property="bpa:ControlHelper.FocusBorderBrush" Value="{Binding Path=(bpa:ControlHelper.FocusedForegroundBrush), RelativeSource={RelativeSource Self}}" />
        <Setter Property="ItemContainerStyle" Value="{StaticResource LineTabItem}" />
    </Style>

    <Style x:Key="CardTabItem" TargetType="{x:Type TabItem}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
        <Setter Property="Foreground" Value="{Binding Path=(bpa:HeaderHelper.Foreground), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="Padding" Value="{Binding Path=(bpa:HeaderHelper.Padding), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="HorizontalAlignment" Value="{Binding Path=(bpa:HeaderHelper.HorizontalAlignment), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="VerticalAlignment" Value="{Binding Path=(bpa:HeaderHelper.VerticalAlignment), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="FontSize" Value="{Binding Path=(bpa:HeaderHelper.FontSize), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="FontWeight" Value="{Binding Path=(bpa:HeaderHelper.FontWeight), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="FontFamily" Value="{Binding Path=(bpa:HeaderHelper.FontFamily), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="bpa:TabControlHelper.IsClearable" Value="{Binding Path=(bpa:TabControlHelper.IsClearable), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="bpa:ControlHelper.FocusedForegroundBrush" Value="{Binding Path=(bpa:ControlHelper.FocusedForegroundBrush), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="bpa:ControlHelper.CornerRadius" Value="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="bpa:ControlHelper.MaskOpacity" Value="{Binding Path=(bpa:ControlHelper.MaskOpacity), RelativeSource={RelativeSource AncestorType=TabControl}}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Grid x:Name="templateRoot"
                          Margin="{Binding Path=(bpa:HeaderHelper.Margin), RelativeSource={RelativeSource AncestorType=TabControl}}"
                          SnapsToDevicePixels="True">
                        <bpa:ControlMask x:Name="mask"
                                         Background="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                         CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                         IsActive="{TemplateBinding IsSelected}"
                                         MaskOpacity="{Binding Path=(bpa:ControlHelper.MaskOpacity), RelativeSource={RelativeSource Mode=TemplatedParent}}" />

                        <DockPanel x:Name="contentPanel"
                                   Margin="{TemplateBinding Padding}"
                                   HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                                   VerticalAlignment="{TemplateBinding VerticalAlignment}">
                            <Button x:Name="clearButton"
                                    Style="{StaticResource TextButton}"
                                    Margin="5 0 0 0"
                                    Padding="2"
                                    bpa:ButtonHelper.Shape="Circle"
                                    bpa:ControlHelper.FocusedBrush="{DynamicResource MaskDark}"
                                    DockPanel.Dock="Right"
                                    Foreground="{TemplateBinding Foreground}"
                                    Visibility="Hidden">
                                <bpa:Icon Type="CloseLine" />
                            </Button>
                            <ContentPresenter x:Name="contentPresenter"
                                              ContentSource="Header"
                                              Focusable="False"
                                              RecognizesAccessKey="True"
                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </DockPanel>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Left">
                            <Setter Property="HorizontalAlignment" Value="Stretch" />
                            <Setter TargetName="contentPresenter" Property="HorizontalAlignment" Value="Center" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}" Value="Right">
                            <Setter Property="HorizontalAlignment" Value="Stretch" />
                            <Setter TargetName="contentPresenter" Property="HorizontalAlignment" Value="Center" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Path=(bpa:TabControlHelper.IsClearable), RelativeSource={RelativeSource Self}}" Value="False">
                            <Setter TargetName="clearButton" Property="Visibility" Value="Collapsed" />
                        </DataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="True" />
                                <Condition Binding="{Binding Path=(bpa:TabControlHelper.IsClearable), RelativeSource={RelativeSource Self}}" Value="True" />
                            </MultiDataTrigger.Conditions>
                            <Setter TargetName="clearButton" Property="Visibility" Value="Visible" />
                        </MultiDataTrigger>
                        <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True">
                            <Setter Property="Foreground" Value="{Binding Path=(bpa:ControlHelper.FocusedForegroundBrush), RelativeSource={RelativeSource Mode=Self}}" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="False">
                            <Setter TargetName="templateRoot" Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="CardTabControl"
           BasedOn="{StaticResource RubyerTabControl}"
           TargetType="{x:Type TabControl}">
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="bpa:ControlHelper.CornerRadius" Value="{DynamicResource AllControlCornerRadius}" />
        <Setter Property="bpa:ControlHelper.FocusedForegroundBrush" Value="{DynamicResource WhiteForeground}" />
        <Setter Property="bpa:ControlHelper.FocusedBrush" Value="{DynamicResource Primary}" />
        <Setter Property="ItemContainerStyle" Value="{StaticResource CardTabItem}" />
        <Setter Property="bpa:HeaderHelper.Padding" Value="10 5" />
        <Setter Property="bpa:HeaderHelper.Margin" Value="2 1" />
        <Setter Property="bpa:HeaderHelper.Foreground" Value="{DynamicResource DefaultForeground}" />
        <Setter Property="bpa:HeaderHelper.Background" Value="{DynamicResource HeaderBackground}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">
                    <Grid x:Name="templateRoot"
                          ClipToBounds="True"
                          KeyboardNavigation.TabNavigation="Local"
                          SnapsToDevicePixels="True">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition x:Name="ColumnDefinition0" />
                            <ColumnDefinition x:Name="ColumnDefinition1" Width="0" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition x:Name="RowDefinition0" Height="Auto" />
                            <RowDefinition x:Name="RowDefinition1" Height="*" />
                        </Grid.RowDefinitions>

                        <Border x:Name="headerPanel"
                                Grid.Row="0"
                                Grid.Column="0"
                                Padding="2"
                                Background="{Binding Path=(bpa:HeaderHelper.Background), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}">
                            <ScrollViewer Style="{StaticResource OnlyArrowScrollViewer}"
                                          bpa:ScrollViewerHelper.HorizontalDelta="150"
                                          bpa:ScrollViewerHelper.VerticalDelta="75"
                                          Background="Transparent"
                                          Foreground="{Binding Path=(bpa:HeaderHelper.Foreground), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                          HorizontalScrollBarVisibility="Auto"
                                          VerticalScrollBarVisibility="Auto">
                                <StackPanel x:Name="headerStackPanel" Orientation="Horizontal">
                                    <TabPanel Panel.ZIndex="1"
                                              IsItemsHost="True"
                                              KeyboardNavigation.TabIndex="1" />
                                    <Button x:Name="PART_AddButton"
                                            Style="{StaticResource TextButton}"
                                            Margin="5 0 0 0"
                                            bpa:ButtonHelper.Shape="Circle"
                                            bpa:ControlHelper.FocusedBrush="{Binding Path=(bpa:ControlHelper.FocusedBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                            Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType=ScrollViewer}}"
                                            Visibility="{Binding Path=(bpa:TabControlHelper.IsShowAddButton), Converter={StaticResource BooleanToVisibleConverter}, RelativeSource={RelativeSource Mode=TemplatedParent}}">
                                        <bpa:Icon Type="AddLine" />
                                    </Button>
                                </StackPanel>
                            </ScrollViewer>
                        </Border>


                        <Border x:Name="contentPanel"
                                Grid.Row="1"
                                Grid.Column="0"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                KeyboardNavigation.DirectionalNavigation="Contained"
                                KeyboardNavigation.TabIndex="2"
                                KeyboardNavigation.TabNavigation="Local">

                            <ContentPresenter x:Name="PART_SelectedContentHost"
                                              Margin="{TemplateBinding Padding}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                              ContentSource="SelectedContent"
                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="TabStripPlacement" Value="Bottom">
                            <Setter TargetName="RowDefinition0" Property="Height" Value="*" />
                            <Setter TargetName="RowDefinition1" Property="Height" Value="Auto" />
                            <Setter TargetName="contentPanel" Property="BorderThickness" Value="0" />
                            <Setter TargetName="contentPanel" Property="Grid.Row" Value="0" />
                            <Setter TargetName="headerPanel" Property="Grid.Row" Value="2" />
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Left">
                            <Setter TargetName="ColumnDefinition0" Property="Width" Value="Auto" />
                            <Setter TargetName="ColumnDefinition1" Property="Width" Value="*" />
                            <Setter TargetName="RowDefinition0" Property="Height" Value="*" />
                            <Setter TargetName="RowDefinition1" Property="Height" Value="0" />
                            <Setter TargetName="contentPanel" Property="Grid.Column" Value="2" />
                            <Setter TargetName="contentPanel" Property="Grid.Row" Value="0" />
                            <Setter TargetName="headerPanel" Property="Grid.Column" Value="0" />
                            <Setter TargetName="headerPanel" Property="Grid.Row" Value="0" />
                            <Setter TargetName="headerStackPanel" Property="Orientation" Value="Vertical" />
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Right">
                            <Setter TargetName="ColumnDefinition0" Property="Width" Value="*" />
                            <Setter TargetName="ColumnDefinition1" Property="Width" Value="Auto" />
                            <Setter TargetName="RowDefinition0" Property="Height" Value="*" />
                            <Setter TargetName="RowDefinition1" Property="Height" Value="0" />
                            <Setter TargetName="contentPanel" Property="Grid.Column" Value="0" />
                            <Setter TargetName="contentPanel" Property="Grid.Row" Value="0" />
                            <Setter TargetName="headerPanel" Property="Grid.Column" Value="2" />
                            <Setter TargetName="headerPanel" Property="Grid.Row" Value="0" />
                            <Setter TargetName="headerStackPanel" Property="Orientation" Value="Vertical" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="templateRoot" Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>