<local:WidgetContent x:Class="Memenim.Framework.Widgets.IconToggleButton"
                     d:DataContext="{d:DesignInstance local:IconToggleButton}"
                     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                     xmlns:local="clr-namespace:Memenim.Framework.Widgets"
                     xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
                     mc:Ignorable="d"
                     d:DesignWidth="50" d:DesignHeight="50">

    <local:WidgetContent.Resources>
        <SolidColorBrush x:Key="IconButton.Static.Background"
                         Color="Transparent"/>
        <SolidColorBrush x:Key="IconButton.Border"
                         Color="#00FFFFFF"/>
        <SolidColorBrush x:Key="IconButton.MouseOver.Background"
                         Color="#C8AAAAAA"/>
        <SolidColorBrush x:Key="IconButton.Pressed.Background"
                         Color="#E54D4D4D"/>
        <SolidColorBrush x:Key="IconButton.Disabled.Background"
                         Color="Transparent"/>
        <SolidColorBrush x:Key="IconButton.Disabled.Foreground"
                         Color="#FF838383"/>

        <Style x:Key="IconToggleButton"
               TargetType="ToggleButton">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                        <Border x:Name="PART_Border"
                                Background="{StaticResource IconButton.Static.Background}"
                                BorderBrush="{StaticResource IconButton.Border}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                SnapsToDevicePixels="true">
                            <ContentPresenter x:Name="PART_ContentPresenter"
                                              Focusable="False"
                                              RecognizesAccessKey="True"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                              Margin="{TemplateBinding Padding}"/>
                        </Border>

                        <ControlTemplate.Triggers>
                            <Trigger Property="IsChecked"
                                     Value="true">
                                <Setter TargetName="PART_Border"
                                        Property="BorderBrush"
                                        Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
                            </Trigger>
                            <Trigger Property="IsMouseOver"
                                     Value="true">
                                <Setter TargetName="PART_Border"
                                        Property="Background"
                                        Value="{StaticResource IconButton.MouseOver.Background}"/>
                                <Setter TargetName="PART_Border"
                                        Property="BorderBrush"
                                        Value="{StaticResource IconButton.Border}"/>
                            </Trigger>
                            <Trigger Property="IsPressed"
                                     Value="true">
                                <Setter TargetName="PART_Border"
                                        Property="Background"
                                        Value="{StaticResource IconButton.Pressed.Background}"/>
                                <Setter TargetName="PART_Border"
                                        Property="BorderBrush"
                                        Value="{StaticResource IconButton.Border}"/>
                            </Trigger>
                            <Trigger Property="IsEnabled"
                                     Value="false">
                                <Setter TargetName="PART_Border"
                                        Property="Background"
                                        Value="{StaticResource IconButton.Disabled.Background}"/>
                                <Setter TargetName="PART_Border"
                                        Property="BorderBrush"
                                        Value="{StaticResource IconButton.Border}"/>
                                <Setter TargetName="PART_ContentPresenter"
                                        Property="TextElement.Foreground"
                                        Value="{StaticResource IconButton.Disabled.Foreground}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </local:WidgetContent.Resources>
    
    <Grid>
        <ToggleButton Style="{StaticResource IconToggleButton}"
                      IsChecked="{Binding Path=IsChecked, Mode=TwoWay}"
                      Click="Button_Click">
            <iconPacks:PackIconControl Width="{Binding Path=IconSize}"
                                       Height="{Binding Path=IconSize}"
                                       Kind="{Binding Path=IconKind}"
                                       Foreground="{Binding Path=IconForeground}"/>
        </ToggleButton>
    </Grid>
</local:WidgetContent>
