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

    <!-- FavoritesButtonStyle -->
    <Style TargetType="{x:Type local:FavoritesButton}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Margin" Value="3" />
        <Setter Property="BorderBrush" Value="{DynamicResource FavoritesButton.BorderBrush}"/>
        <Setter Property="Background" Value="{DynamicResource FavoritesButton.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="4">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <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 FavoritesButton.Text.Foreground}"
                                       Margin="5,0,5,5">
                                <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 Text="{TemplateBinding Key}"
                                   HorizontalAlignment="Left" 
                                   Margin="3,2,0,0" 
                                   Foreground="{DynamicResource FavoritesButton.Key.Foreground}" 
                                   Padding="0" >
                            </TextBlock>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" TargetName="BD" Value="{DynamicResource FavoritesButton.MouseOver.Background}" />
                        </Trigger>
                        <Trigger Property="IsFocused" Value="True">
                            <Setter Property="BorderBrush" Value="{DynamicResource FavoritesButton.Focused.BorderBrush}" />
                            <Setter Property="BorderThickness" Value="2" />
                        </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>
