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

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="../../Basic/Geometries.xaml"/>
        <ResourceDictionary Source="../../Basic/Converters.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="RateRateItemBaseStyle" TargetType="controls:RateItem">
        <Setter Property="Margin" Value="{Binding ItemMargin,RelativeSource={RelativeSource  AncestorType=controls:Rate}}"/>
        <Setter Property="Width" Value="{Binding ItemWidth,RelativeSource={RelativeSource  AncestorType=controls:Rate}}"/>
        <Setter Property="Height" Value="{Binding ItemHeight,RelativeSource={RelativeSource  AncestorType=controls:Rate}}"/>
        <Setter Property="AllowHalf" Value="{Binding AllowHalf,RelativeSource={RelativeSource  AncestorType=controls:Rate}}"/>
        <Setter Property="AllowClear" Value="{Binding AllowClear,RelativeSource={RelativeSource  AncestorType=controls:Rate}}"/>
        <Setter Property="Icon" Value="{Binding Icon,RelativeSource={RelativeSource  AncestorType=controls:Rate}}"/>
        <Setter Property="IsReadOnly" Value="{Binding IsReadOnly,RelativeSource={RelativeSource  AncestorType=controls:Rate}}"/>
        <Setter Property="Background" Value="{Binding Background,RelativeSource={RelativeSource  AncestorType=controls:Rate}}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:RateItem">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="OnMouseEnter">
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="CanvasRoot">
                                <LinearDoubleKeyFrame KeyTime="0" Value="1.1"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="CanvasRoot">
                                <LinearDoubleKeyFrame KeyTime="0" Value="1.1"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                        <Storyboard x:Key="OnMouseLeave">
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="CanvasRoot">
                                <LinearDoubleKeyFrame KeyTime="0" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="CanvasRoot">
                                <LinearDoubleKeyFrame KeyTime="0" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Canvas x:Name="CanvasRoot" RenderTransformOrigin="0.5,0.5">
                        <Canvas.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform/>
                            </TransformGroup>
                        </Canvas.RenderTransform>
                        <Path Width="{Binding ActualWidth,ElementName=CanvasRoot}" Height="{Binding ActualHeight,ElementName=CanvasRoot}" Data="{TemplateBinding Icon}" Fill="{TemplateBinding Background}" Stretch="Uniform"/>
                        <Border x:Name="PART_Icon" Visibility="Collapsed">
                            <Path Width="{Binding ActualWidth,ElementName=CanvasRoot}" HorizontalAlignment="Left" Height="{Binding ActualHeight,ElementName=CanvasRoot}" Data="{TemplateBinding Icon}" Fill="{TemplateBinding Foreground}" Stretch="Uniform"/>
                        </Border>
                    </Canvas>
                    <ControlTemplate.Triggers>
                        <EventTrigger RoutedEvent="UIElement.MouseEnter" SourceName="CanvasRoot">
                            <BeginStoryboard Storyboard="{StaticResource OnMouseEnter}"/>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="UIElement.MouseLeave" SourceName="CanvasRoot">
                            <BeginStoryboard Storyboard="{StaticResource OnMouseLeave}"/>
                        </EventTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="RateBaseStyle" TargetType="controls:Rate">
        <Setter Property="ItemMargin" Value="5,0"/>
        <Setter Property="HorizontalAlignment" Value="Left"/>
        <Setter Property="VerticalAlignment" Value="Top"/>
        <Setter Property="Icon" Value="{StaticResource StarGeometry}"/>
        <Setter Property="Foreground" Value="{DynamicResource PrimaryBrush}"/>
        <Setter Property="Background" Value="{DynamicResource BackgroundBrush}"/>
        <Setter Property="ItemContainerStyle" Value="{StaticResource RateRateItemBaseStyle}"/>
        <Setter Property="Text" Value="{Binding Value,RelativeSource={RelativeSource Self},StringFormat={}{0:0.0}}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:Rate">
                    <StackPanel Background="Transparent" Orientation="Horizontal">
                        <UniformGrid Rows="1" Margin="-5,0" x:Name="PART_Panel"/>
                        <TextBlock Visibility="{TemplateBinding ShowText,Converter={StaticResource Boolean2VisibilityConverter}}" Text="{TemplateBinding Text}" Margin="10,0,0,0" VerticalAlignment="Center"/>
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>