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

    <!-- TabButtonStyle -->
    <Style TargetType="{x:Type local:TabButton}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="BorderThickness" Value="{DynamicResource TabButton.Border.Thickness}"/>
        <Setter Property="Margin" Value="{DynamicResource TabButton.Margin}" />
        <Setter Property="BorderBrush" Value="{DynamicResource TabButton.BorderBrush}"/>
        <Setter Property="Background" Value="{DynamicResource TabButton.Background}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:MButton}">
                    <Border x:Name="BD"
                            BorderBrush="{TemplateBinding BorderBrush}" 
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Margin="{TemplateBinding Margin}"
                            Background="{TemplateBinding Background}"
                            SnapsToDevicePixels="True"
                            CornerRadius="{DynamicResource TabButton.CornerRadius}">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="{DynamicResource TabButton.ImageHeight}"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <Image Grid.Row="0" 
                                   Source="{TemplateBinding Image}" 
                                   Stretch="Uniform"
                                   Margin="5">
                            </Image>
                            <TextBlock x:Name="ButtonText" Grid.Row="1" 
                                       Text="{TemplateBinding Text}" 
                                       TextWrapping="Wrap" 
                                       TextAlignment="Center" 
                                       TextTrimming="CharacterEllipsis"
                                       Foreground="{DynamicResource TabButton.Text.Foreground}"
                                       FontSize="{DynamicResource TabButton.Text.FontSize}"
                                       FontFamily="{DynamicResource TabButton.Text.FontFamily}"
                                       Margin="5,0,5,5"
                                       FontWeight="{DynamicResource TabButton.Text.FontWeight}">
                                <TextBlock.ToolTip>
                                  <StackPanel Orientation="Vertical">
                                    <Label Content="{TemplateBinding Text}" HorizontalContentAlignment="Center" />
                                        <TextBlock x:Name="ToolTipPanelDescription" Text="{TemplateBinding Description}" TextWrapping="Wrap" TextAlignment="Left" MaxWidth="200"/>
                                  </StackPanel>
                                </TextBlock.ToolTip>
                            </TextBlock>
                            <TextBlock x:Name="KeyText" Text="{TemplateBinding Key}"
                                   HorizontalAlignment="Left" 
                                   Margin="3,2,0,0" 
                                   Foreground="{DynamicResource TabButton.Key.Foreground}" 
                                   FontSize="{DynamicResource TabButton.Key.FontSize}"
                                   FontFamily="{DynamicResource TabButton.Key.FontFamily}"
                                   FontWeight="{DynamicResource TabButton.Key.FontWeight}"
                                   Padding="0" >
                            </TextBlock>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" TargetName="BD" Value="{DynamicResource TabButton.MouseOver.Background}" />
                            <Setter Property="Foreground" TargetName="KeyText" Value="{DynamicResource TabButton.MouseOver.Foreground}" />
                            <Setter Property="Foreground" TargetName="ButtonText" Value="{DynamicResource TabButton.MouseOver.Foreground}" />
                        </Trigger>
                        <Trigger Property="IsFocused" Value="True">
                            <Setter Property="BorderBrush" Value="{DynamicResource TabButton.Focused.BorderBrush}" />
                        </Trigger>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text}" Value="">
                            <Setter Property="ToolTip" TargetName="ButtonText" Value="" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Description}" Value="">
                            <Setter Property="Visibility" TargetName="ToolTipPanelDescription" Value="Collapsed" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
