<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:IconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
                    xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz">

    <Style TargetType="{x:Type Thumb}" x:Key="InvisibleThumbStyle">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <Grid Background="{TemplateBinding Background}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="CustomHeaderItemTemplate" TargetType="{x:Type dragablz:DragablzItem}">
        <Setter Property="FocusVisualStyle" Value="{StaticResource MahAppsFocusVisual}"/>
        <Setter Property="Foreground" Value="{DynamicResource BlackBrush}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type dragablz:DragablzItem}">
                    <Grid x:Name="templateRoot" SnapsToDevicePixels="true">
                        <Border x:Name="Rectangle" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <ContentPresenter Content="{TemplateBinding ContentControl.Content}" ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}" HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" Margin="{TemplateBinding Control.Padding}" x:Name="contentPresenter" />
                                <Thumb Grid.Column="0" HorizontalAlignment="Stretch" VerticalContentAlignment="Stretch" x:Name="PART_Thumb" Style="{StaticResource MahAppsInvisibleThumbStyle}" />
                            </Grid>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="dragablz:TabablzControl.IsWrappingTabItem" Value="True">
                            <Setter TargetName="contentPresenter" Property="Content" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataContext.Header}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="DefaultTabablzControl" TargetType="{x:Type dragablz:TabablzControl}" BasedOn="{StaticResource MahAppsTabablzControlStyle}" >
        <Setter Property="BorderThickness" Value="0,1,0,0" />
        <Setter Property="BorderBrush" Value="{DynamicResource GrayBrush8}" />
        <Setter Property="ItemContainerStyle" Value="{StaticResource CustomHeaderItemTemplate}" />
        <Setter Property="AdjacentHeaderItemOffset" Value="0" />
        <Setter Property="ContentTemplateSelector" Value="{x:Null}" />
        <Setter Property="HeaderItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Border BorderBrush="{DynamicResource GrayBrush8}" BorderThickness="0,0,1,0">
                        <Grid>
                            <Grid.InputBindings>
                                <MouseBinding Command="dragablz:TabablzControl.CloseItemCommand" Gesture="MiddleClick" />
                            </Grid.InputBindings>
                            <StackPanel Orientation="Horizontal">
                                <Grid ToolTip="{Binding Header}">
                                    <TextBlock Text="{Binding Header}" VerticalAlignment="Center" Width="150" Margin="10">
                                        <TextBlock.Style>
                                            <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource HeaderTextBlock}">
                                                <Setter Property="FontSize" Value="18" />
                                                <Setter Property="Foreground" Value="{DynamicResource GrayBrush3}" />
                                                <Style.Triggers>
                                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type dragablz:DragablzItem}}, Path=IsSelected}" Value="True">
                                                        <Setter Property="Foreground" Value="{DynamicResource AccentColorBrush}" />
                                                    </DataTrigger>
                                                </Style.Triggers>
                                            </Style>
                                        </TextBlock.Style>
                                    </TextBlock>
                                    <Thumb Style="{DynamicResource InvisibleThumbStyle}" dragablz:DragablzItem.IsCustomThumb="True" />
                                </Grid>
                                <Button Style="{StaticResource CleanButton}" Command="dragablz:TabablzControl.CloseItemCommand" ToolTip="{DynamicResource String_Close}" Margin="0,0,10,0">
                                    <Rectangle Width="16" Height="16">
                                        <Rectangle.OpacityMask>
                                            <VisualBrush Stretch="Uniform" Visual="{IconPacks:Material Kind=WindowClose}" />
                                        </Rectangle.OpacityMask>
                                        <Rectangle.Style>
                                            <Style TargetType="{x:Type Rectangle}">
                                                <Setter Property="Fill" Value="{DynamicResource GrayBrush3}" />
                                                <Style.Triggers>
                                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Button}}, Path=IsMouseOver}" Value="True">
                                                        <Setter Property="Fill" Value="{DynamicResource GrayBrush5}" />
                                                    </DataTrigger>
                                                </Style.Triggers>
                                            </Style>
                                        </Rectangle.Style>
                                    </Rectangle>
                                </Button>
                            </StackPanel>
                        </Grid>
                    </Border>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="HeaderSuffixContent">
            <Setter.Value>
                <Grid HorizontalAlignment="Left" Width="40" Height="44">
                    <Button Style="{StaticResource CleanButton}" Command="dragablz:TabablzControl.AddItemCommand" ToolTip="{DynamicResource String_NewTab}" Focusable="False">
                        <Rectangle Width="20" Height="20">
                            <Rectangle.OpacityMask>
                                <VisualBrush Stretch="Fill" Visual="{IconPacks:Material Kind=Plus}" />
                            </Rectangle.OpacityMask>
                            <Rectangle.Style>
                                <Style TargetType="{x:Type Rectangle}">
                                    <Setter Property="Fill" Value="{DynamicResource GrayBrush3}" />
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Button}}, Path=IsMouseOver}" Value="True">
                                            <Setter Property="Fill" Value="{DynamicResource GrayBrush5}" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </Rectangle.Style>
                        </Rectangle>
                    </Button>
                </Grid>
            </Setter.Value>
        </Setter>
        <Setter Property="ContentTemplate">
            <Setter.Value>
                <DataTemplate>
                    <ContentControl Content="{Binding Content}" />
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>