<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:local="clr-namespace:MaxLauncher;assembly=MaxLauncher">

    <Style TargetType="{x:Type local:MainTabControl}">
        <Setter Property="Margin" Value="20,20,20,20"/>
        <Setter Property="BorderThickness" Value="1,0,1,1"/>
        <Setter Property="BorderBrush" Value="{DynamicResource TabItemControl.BorderBrush}"/>
        <Setter Property="Background" Value="{DynamicResource TabItemControl.Selected.Background}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">
                    <Grid ClipToBounds="True" SnapsToDevicePixels="True" KeyboardNavigation.TabNavigation="Local">
                        <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>
                        <UniformGrid x:Name="HeaderPanel" Grid.Column="0" Grid.Row="0" IsItemsHost="True" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1" Rows="1"
                                     Margin="0,0,0,0"/>
                        <Border x:Name="ContentPanel" 
                                Grid.Column="0" 
                                Grid.Row="1" 
                                BorderThickness="{TemplateBinding BorderThickness}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                Background="{TemplateBinding Background}" 
                                KeyboardNavigation.DirectionalNavigation="Contained" 
                                KeyboardNavigation.TabIndex="2" 
                                KeyboardNavigation.TabNavigation="Local" >
                            <ContentPresenter x:Name="PART_SelectedContentHost" 
                                              ContentTemplate="{TemplateBinding SelectedContentTemplate}" 
                                              Content="{TemplateBinding SelectedContent}" 
                                              ContentStringFormat="{TemplateBinding SelectedContentStringFormat}" 
                                              ContentSource="SelectedContent" Margin="{TemplateBinding Padding}" 
                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:TabItemControl}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="{DynamicResource TabItemControl.BorderBrush}"/>
        <Setter Property="Foreground" Value="{DynamicResource TabItemControl.UnSelected.Text.Foreground}"/>
        <Setter Property="Background" Value="{DynamicResource TabItemControl.UnSelected.Background}"/>
        <Setter Property="Margin" Value="0,0,0,0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Grid>
                        <Border x:Name="BD" 
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Padding="{TemplateBinding Padding}" 
                                Background="{TemplateBinding Background}" 
                                BorderBrush="{TemplateBinding BorderBrush}"
                                CornerRadius="8,8,0,0"
                                Margin="{TemplateBinding Margin}">
                            <Grid x:Name="Content">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="*"/>
                                </Grid.RowDefinitions>
                                <TextBlock x:Name="Key" Grid.Row="0" 
                                           Text="{Binding Key, RelativeSource={RelativeSource TemplatedParent}}" 
                                           HorizontalAlignment="Left" 
                                           VerticalAlignment="Top"
                                           Margin="3,2,0,0"
                                           Foreground="{DynamicResource TabItemControl.UnSelected.Key.Foreground}"/>
                                <TextBlock x:Name="Header" Grid.Row="1" 
                                           Text="{TemplateBinding Header}"
                                           TextWrapping="Wrap" 
                                           TextAlignment="Center"
                                           Margin="0,0,0,3"
                                           Foreground="{TemplateBinding Foreground}"/>
                            </Grid>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Background" TargetName="BD" Value="{DynamicResource TabItemControl.MouseOver.Background}"/>
                        </Trigger>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter Property="Panel.ZIndex" Value="1"/>
                            <Setter Property="Margin" TargetName="BD" Value="0,0,0,-1"/>
                            <Setter Property="BorderThickness" TargetName="BD" Value="1,1,1,0"/>
                            <Setter Property="Background" TargetName="BD" Value="{DynamicResource TabItemControl.Selected.Background}"/>
                            <Setter Property="Foreground" TargetName="Key" Value="{DynamicResource TabItemControl.Selected.Key.Foreground}"/>
                            <Setter Property="Foreground" TargetName="Header" Value="{DynamicResource TabItemControl.Selected.Text.Foreground}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
