<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">

    <!-- *********************************************************************************** -->
    <!-- MainTabControlStyle -->
    <Style TargetType="{x:Type local:MainTabControl}">
        <Setter Property="Margin" Value="{DynamicResource MainTab.Margin}"/>
        <Setter Property="BorderThickness" Value="{DynamicResource MainTab.Border.Thickness}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource MainTab.BorderBrush}"/>
        <Setter Property="Background" Value="{DynamicResource MainTab.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="{DynamicResource MainTab.Tab.UnSelected.Border.Thickness}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource MainTab.BorderBrush}"/>
        <Setter Property="Foreground" Value="{DynamicResource MainTab.Tab.UnSelected.Text.Foreground}"/>
        <Setter Property="Background" Value="{DynamicResource MainTab.Tab.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="{DynamicResource MainTab.Tab.CornerRadius}"
                                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"
                                           FontSize="{DynamicResource MainTab.Tab.Key.FontSize}"
                                           FontFamily="{DynamicResource MainTab.Tab.Key.FontFamily}"
                                           FontWeight="{DynamicResource MainTab.Tab.Key.FontWeight}"
                                           Foreground="{DynamicResource MainTab.Tab.UnSelected.Key.Foreground}"/>
                                <TextBlock x:Name="Header" Grid.Row="1" 
                                           Text="{TemplateBinding Header}"
                                           TextWrapping="Wrap" 
                                           TextAlignment="Center"
                                           Margin="0,0,0,3"
                                           FontSize="{DynamicResource MainTab.Tab.Text.FontSize}"
                                           FontFamily="{DynamicResource MainTab.Tab.Text.FontFamily}"
                                           FontWeight="{DynamicResource MainTab.Tab.Text.FontWeight}"
                                           Foreground="{TemplateBinding Foreground}"/>
                            </Grid>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Background" TargetName="BD" Value="{DynamicResource MainTab.Tab.MouseOver.Background}"/>
                            <Setter Property="Foreground" TargetName="Key" Value="{DynamicResource MainTab.Tab.MouseOver.Foreground}"/>
                            <Setter Property="Foreground" TargetName="Header" Value="{DynamicResource MainTab.Tab.MouseOver.Foreground}"/>
                        </Trigger>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter Property="Panel.ZIndex" Value="1"/>
                            <Setter Property="Margin" TargetName="BD" Value="0,0,0,0"/>
                            <Setter Property="BorderThickness" TargetName="BD" Value="{DynamicResource MainTab.Tab.Selected.Border.Thickness}"/>
                            <Setter Property="Background" TargetName="BD" Value="{DynamicResource MainTab.Tab.Selected.Background}"/>
                            <Setter Property="Foreground" TargetName="Key" Value="{DynamicResource MainTab.Tab.Selected.Key.Foreground}"/>
                            <Setter Property="Foreground" TargetName="Header" Value="{DynamicResource MainTab.Tab.Selected.Text.Foreground}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
