<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:hc="clr-namespace:HandyControl.Controls">

    <Style
        x:Key="ButtonBaseStyle"
        TargetType="Button"
        BasedOn="{StaticResource ButtonBaseBaseStyle}">
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Background" Value="{DynamicResource RegionBrush}" />
        <Setter Property="hc:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <hc:SimplePanel>
                        <Border Background="{TemplateBinding Background}" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}" />
                        <Border
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}">
                            <StackPanel
                                Margin="{TemplateBinding Padding}"
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                Orientation="Horizontal">
                                <Path
                                    x:Name="PathMain"
                                    Width="{TemplateBinding hc:IconElement.Width}"
                                    Height="{TemplateBinding hc:IconElement.Height}"
                                    Data="{TemplateBinding hc:IconElement.Geometry}"
                                    Fill="{TemplateBinding Foreground}"
                                    SnapsToDevicePixels="True"
                                    Stretch="Uniform" />
                                <ContentPresenter
                                    x:Name="ContentPresenterMain"
                                    Margin="6,0,0,0"
                                    VerticalAlignment="Center"
                                    RecognizesAccessKey="True"
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                            </StackPanel>
                        </Border>
                    </hc:SimplePanel>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Content" Value="{x:Null}">
                            <Setter TargetName="ContentPresenterMain" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                        <Trigger Property="hc:IconElement.Geometry" Value="{x:Null}">
                            <Setter TargetName="PathMain" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="ContentPresenterMain" Property="Margin" Value="0" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Opacity" Value=".9" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Opacity" Value=".6" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Opacity" Value="0.4" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style
        x:Key="ButtonDashedBaseStyle"
        TargetType="Button"
        BasedOn="{StaticResource ButtonBaseStyle}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <hc:DashedBorder
                        Background="Transparent"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderDashArray="3,2"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}">
                        <StackPanel
                            Margin="{TemplateBinding Padding}"
                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                            Orientation="Horizontal">
                            <Path
                                x:Name="PathMain"
                                Width="{TemplateBinding hc:IconElement.Width}"
                                Height="{TemplateBinding hc:IconElement.Height}"
                                Data="{TemplateBinding hc:IconElement.Geometry}"
                                Fill="{TemplateBinding Foreground}"
                                SnapsToDevicePixels="True"
                                Stretch="Uniform" />
                            <ContentPresenter
                                x:Name="ContentPresenterMain"
                                Margin="6,0,0,0"
                                VerticalAlignment="Center"
                                RecognizesAccessKey="True"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </StackPanel>
                    </hc:DashedBorder>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Content" Value="{x:Null}">
                            <Setter TargetName="ContentPresenterMain" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                        <Trigger Property="hc:IconElement.Geometry" Value="{x:Null}">
                            <Setter TargetName="PathMain" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="ContentPresenterMain" Property="Margin" Value="0" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style
        x:Key="ButtonGroupItemBaseStyle"
        TargetType="Button"
        BasedOn="{StaticResource BaseStyle}">
        <Setter Property="Background" Value="{DynamicResource RegionBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="hc:BorderElement.CornerRadius" Value="0" />
        <Setter Property="Height" Value="{StaticResource DefaultControlHeight}" />
        <Setter Property="Padding" Value="10,0" />
        <Setter Property="Margin" Value="-1,0,0,0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Border
                        x:Name="BorderRoot"
                        Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}">
                        <StackPanel
                            Margin="{TemplateBinding Padding}"
                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                            Orientation="Horizontal">
                            <Path
                                x:Name="PathMain"
                                Width="{TemplateBinding hc:IconElement.Width}"
                                Height="{TemplateBinding hc:IconElement.Height}"
                                Data="{TemplateBinding hc:IconElement.Geometry}"
                                Fill="{TemplateBinding Foreground}"
                                SnapsToDevicePixels="True"
                                Stretch="Uniform" />
                            <ContentPresenter
                                x:Name="contentPresenter"
                                Margin="6,0,0,0"
                                VerticalAlignment="Center"
                                RecognizesAccessKey="True"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </StackPanel>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="contentPresenter" Property="TextElement.Foreground" Value="{DynamicResource PrimaryBrush}" />
                        </Trigger>
                        <Trigger Property="Content" Value="{x:Null}">
                            <Setter TargetName="contentPresenter" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                        <Trigger Property="hc:IconElement.Geometry" Value="{x:Null}">
                            <Setter TargetName="PathMain" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="contentPresenter" Property="Margin" Value="0" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Opacity" Value="0.4" />
            </Trigger>
            <DataTrigger Binding="{Binding Orientation, RelativeSource={RelativeSource AncestorType=hc:ButtonGroup}}" Value="Vertical">
                <Setter Property="Margin" Value="0,-1,0,0" />
            </DataTrigger>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Background" Value="{DynamicResource BorderBrush}" />
            </Trigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>
