<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
                    xmlns:behaviours="http://metro.mahapps.com/winfx/xaml/shared"

                    xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
                    xmlns:converter="clr-namespace:MahApps.Metro.IconPacks.Converter;assembly=MahApps.Metro.IconPacks.Core">
    <SolidColorBrush x:Key="TabItemPanelBackgroundBrush" Color="{StaticResource MahApps.Colors.Gray8}" />
    <SolidColorBrush x:Key="TabItemBackgroundIsSelectedBrush" Color="{StaticResource MahApps.Colors.Gray2}" />
    <SolidColorBrush x:Key="TabItemBackgroundIsMouseOverBrush" Color="{StaticResource MahApps.Colors.Gray5}" />
    <SolidColorBrush x:Key="TabItemForegroundIsSelectedBrush" Color="{StaticResource MahApps.Colors.IdealForeground}" />
    <SolidColorBrush x:Key="TabItemSelectorBrush" Color="LawnGreen" />
    <SolidColorBrush x:Key="TabControlBackgroundBrush" Color="WhiteSmoke" />

    <Style x:Key="CustomTabItemStyle" TargetType="{x:Type TabItem}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Margin" Value="0" />
        <Setter Property="Padding" Value="10" />
        <Setter Property="MinWidth" Value="100" />
        <Setter Property="FontSize" Value="14" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Grid x:Name="PART_Grid"
                          Background="{TemplateBinding Background}"
                          SnapsToDevicePixels="True"
                          Margin="0">
                        <ContentPresenter x:Name="PART_HeaderContent"
                                          Margin="{TemplateBinding Padding}"
                                          ContentSource="Header"
                                          HorizontalAlignment="Center"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        <Rectangle x:Name="PART_Selector"
                                   VerticalAlignment="Bottom"
                                   Height="4"
                                   Visibility="Collapsed"
                                   Fill="{StaticResource TabItemSelectorBrush}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Trigger.Setters>
                                <Setter Property="Background" Value="{StaticResource TabItemBackgroundIsSelectedBrush}" />
                                <Setter Property="Foreground" Value="{StaticResource TabItemForegroundIsSelectedBrush}" />
                                <Setter TargetName="PART_Selector" Property="Visibility" Value="Visible" />
                            </Trigger.Setters>
                        </Trigger>
                        <Trigger SourceName="PART_Grid" Property="IsMouseOver" Value="True">
                            <Trigger.Setters>
                                <Setter Property="Background" Value="{StaticResource TabItemBackgroundIsMouseOverBrush}" />
                                <Setter Property="Cursor" Value="Hand" />
                            </Trigger.Setters>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="CustomTabControlStyle" TargetType="{x:Type TabControl}">
        <Setter Property="Background" Value="{StaticResource TabControlBackgroundBrush}" />
        <Setter Property="TabStripPlacement" Value="Top" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Margin" Value="0" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="ItemContainerStyle" Value="{StaticResource CustomTabItemStyle}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">
                    <DockPanel LastChildFill="True">
                        <Grid x:Name="HeaderGrid"
                              DockPanel.Dock="Left"
                              Background="{StaticResource TabItemPanelBackgroundBrush}">
                            <TabPanel x:Name="HeaderPanel"
                                      HorizontalAlignment="Center"
                                      Panel.ZIndex="1"
                                      IsItemsHost="True"
                                      KeyboardNavigation.TabIndex="1" />
                        </Grid>
                        <Border x:Name="ContentPanel"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                KeyboardNavigation.DirectionalNavigation="Contained"
                                KeyboardNavigation.TabIndex="2"
                                KeyboardNavigation.TabNavigation="Local"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                            <controls:TransitioningContentControl UseLayoutRounding="True"
                                                                  behaviours:ReloadBehavior.OnSelectedTabChanged="True"
                                                                  RestartTransitionOnContentChange="True"
                                                                  Transition="{TemplateBinding controls:TabControlHelper.Transition}">
                                <ContentPresenter x:Name="PART_SelectedContentHost"
                                                  UseLayoutRounding="False"
                                                  Margin="{TemplateBinding Padding}"
                                                  ContentSource="SelectedContent"
                                                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                            </controls:TransitioningContentControl>
                        </Border>
                    </DockPanel>
                    <ControlTemplate.Triggers>
                        <Trigger Property="TabStripPlacement" Value="Top">
                            <Setter TargetName="HeaderGrid" Property="DockPanel.Dock" Value="Top" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>