<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.MergedDictionaries>

    <Style x:Key="RubyerTimePicker" TargetType="{x:Type bpa:TimePicker}">
        <Setter Property="Background" Value="{DynamicResource ControlBackground}" />
        <Setter Property="BorderBrush" Value="{DynamicResource Border}" />
        <Setter Property="Foreground" Value="{DynamicResource DefaultForeground}" />
        <Setter Property="BorderThickness" Value="{DynamicResource DefaultBorderThickness}" />
        <Setter Property="Padding" Value="0 5" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="SelectedTimeFormat" Value="HH:mm" />
        <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="Focusable" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type bpa:TimePicker}">
                    <Grid x:Name="PART_Root">
                        <TextBox 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}"
                                 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="TimeLine" />
                                </Button>
                            </bpa:InputBoxHelper.PostContent>
                        </TextBox>
                        <Grid x:Name="PART_DisabledVisual"
                              Grid.Row="0"
                              IsHitTestVisible="False"
                              Opacity="0">
                            <Popup x:Name="PART_Popup"
                                   AllowsTransparency="True"
                                   HorizontalOffset="0"
                                   Placement="Bottom"
                                   PlacementTarget="{Binding ElementName=PART_TextBox}"
                                   PopupAnimation="Fade"
                                   StaysOpen="False"
                                   VerticalOffset="5">
                                <bpa:Clock x:Name="PART_Clock" />
                            </Popup>
                        </Grid>
                    </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 TimePicker  -->
    <Style x:Key="FilledTimePicker"
           BasedOn="{StaticResource RubyerTimePicker}"
           TargetType="{x:Type bpa:TimePicker}">
        <Setter Property="BorderBrush" Value="{DynamicResource BorderLighter}" />
        <Setter Property="Background" Value="{DynamicResource BorderLighter}" />
        <Setter Property="bpa:ControlHelper.MouseOverBrush" Value="{DynamicResource BorderLight}" />
    </Style>
</ResourceDictionary>