<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:bpa="clr-namespace:BPA.UIControl">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/BPA.UIControl;component/Themes/TextBox.xaml" />
        <ResourceDictionary Source="pack://application:,,,/BPA.UIControl;component/Themes/Calendar.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="RubyerDatePicker" TargetType="{x:Type DatePicker}">
        <Setter Property="Background" Value="{DynamicResource ControlBackground}" />
        <Setter Property="BorderBrush" Value="{DynamicResource Border}" />
        <Setter Property="BorderThickness" Value="{DynamicResource DefaultBorderThickness}" />
        <Setter Property="CalendarStyle" Value="{StaticResource RubyerCalendar}" />
        <Setter Property="Foreground" Value="{DynamicResource DefaultForeground}" />
        <Setter Property="Padding" Value="0 5" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="IsTodayHighlighted" Value="True" />
        <Setter Property="SelectedDateFormat" Value="Short" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Validation.ErrorTemplate" Value="{StaticResource RubyerValidationErrorTemplate}" />
        <Setter Property="bpa:ControlHelper.CornerRadius" Value="{DynamicResource AllControlCornerRadius}" />
        <Setter Property="bpa:ControlHelper.FocusBorderBrush" Value="{DynamicResource Primary}" />
        <Setter Property="bpa:ControlHelper.MouseOverBrush" Value="{DynamicResource Primary}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DatePicker}">
                    <Grid x:Name="PART_Root">
                        <DatePickerTextBox x:Name="PART_TextBox"
                                           Grid.Row="0"
                                           Grid.Column="0"
                                           Height="Auto"
                                           Padding="{TemplateBinding Padding}"
                                           HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                           VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                           bpa:ControlHelper.CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                           bpa:ControlHelper.FocusBorderBrush="{Binding Path=(bpa:ControlHelper.FocusBorderBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                           bpa:ControlHelper.MouseOverBrush="{Binding Path=(bpa:ControlHelper.MouseOverBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                           bpa:InputBoxHelper.InternalSpacing="{Binding Path=(bpa:InputBoxHelper.InternalSpacing), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                           bpa:InputBoxHelper.IsClearable="{Binding Path=(bpa:InputBoxHelper.IsClearable), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                           bpa:InputBoxHelper.PreContent="{Binding Path=(bpa:InputBoxHelper.PreContent), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                           bpa:InputBoxHelper.Watermark="{Binding Path=(bpa:InputBoxHelper.Watermark), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                           Background="{TemplateBinding Background}"
                                           BorderBrush="{TemplateBinding BorderBrush}"
                                           BorderThickness="{TemplateBinding BorderThickness}"
                                           Focusable="{TemplateBinding Focusable}"
                                           Foreground="{TemplateBinding Foreground}">
                            <bpa:InputBoxHelper.PostContent>
                                <Button x:Name="PART_Button"
                                        Style="{StaticResource TextButton}"
                                        Padding="2"
                                        bpa:ButtonHelper.Shape="Circle"
                                        Focusable="False"
                                        Foreground="{DynamicResource SeconarydText}">
                                    <bpa:Icon Type="Calendar2Line" />
                                </Button>
                            </bpa:InputBoxHelper.PostContent>
                        </DatePickerTextBox>
                        <Popup x:Name="PART_Popup"
                               Margin="5"
                               AllowsTransparency="True"
                               Placement="Bottom"
                               PlacementTarget="{Binding ElementName=PART_TextBox}"
                               PopupAnimation="Fade"
                               StaysOpen="False"
                               VerticalOffset="5" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="bpa:InputBoxHelper.IsRound" Value="True">
                            <Setter Property="bpa:ControlHelper.CornerRadius" Value="{Binding ActualHeight, RelativeSource={RelativeSource Self}, Converter={StaticResource HalfOfDoubleConverter}}" />
                        </Trigger>
                        <Trigger Property="Validation.HasError" Value="True">
                            <Setter Property="BorderBrush" Value="{DynamicResource Error}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--  Filled DatePicker  -->
    <Style x:Key="FilledDatePicker"
           BasedOn="{StaticResource RubyerDatePicker}"
           TargetType="{x:Type DatePicker}">
        <Setter Property="BorderBrush" Value="{DynamicResource BorderLighter}" />
        <Setter Property="Background" Value="{DynamicResource BorderLighter}" />
        <Setter Property="bpa:ControlHelper.MouseOverBrush" Value="{DynamicResource BorderLight}" />
    </Style>
</ResourceDictionary>