<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="FocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle
                        RadiusX="4"
                        RadiusY="4"
                        Style="{StaticResource RectangleFocusVisual}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="FocusVisualRadius0">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle Style="{StaticResource RectangleFocusVisual}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="FocusVisualMargin0">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle
                        Opacity=".6"
                        RadiusX="4"
                        RadiusY="4"
                        SnapsToDevicePixels="true"
                        Stroke="{DynamicResource SecondaryBorderBrush}"
                        StrokeDashArray="1 1"
                        StrokeThickness="2" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="FocusVisualRadius0Margin0">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle
                        Opacity=".6"
                        SnapsToDevicePixels="true"
                        Stroke="{DynamicResource SecondaryBorderBrush}"
                        StrokeDashArray="1 1"
                        StrokeThickness="2" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="InputElementErrorTemplate">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <AdornedElementPlaceholder x:Name="adornedElementPlaceholder" />
            <hc:TransitioningContentControl
                Grid.Row="1"
                ClipToBounds="True"
                TransitionMode="Top2Bottom">
                <TextBlock
                    Margin="2,2,0,0"
                    Foreground="{DynamicResource DangerBrush}"
                    Text="{Binding Path=AdornedElement.(Validation.Errors)[0].ErrorContent, ElementName=adornedElementPlaceholder}" />
            </hc:TransitioningContentControl>
        </Grid>
    </ControlTemplate>

    <Style x:Key="InputElementBaseStyle" TargetType="Control">
        <Setter Property="hc:TitleElement.MarginOnTheLeft" Value="0,7,6,0" />
        <Setter Property="hc:TitleElement.MarginOnTheTop" Value="8,0,0,5" />
        <Setter Property="hc:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}" />
        <Setter Property="MinHeight" Value="{StaticResource DefaultControlHeight}" />
        <Setter Property="Padding" Value="{StaticResource DefaultInputPadding}" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="Background" Value="{DynamicResource RegionBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}" />
        <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Validation.ErrorTemplate" Value="{StaticResource InputElementErrorTemplate}" />
        <Style.Triggers>
            <Trigger Property="Validation.HasError" Value="true">
                <Setter Property="BorderBrush" Value="{DynamicResource DangerBrush}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="BaseStyle" TargetType="Control">
        <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}" />
        <Setter Property="FontSize" Value="{StaticResource TextFontSize}" />
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
    </Style>

</ResourceDictionary>
