<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ui="http://schemas.modernwpf.com/2019"
    xmlns:local="clr-namespace:ModernWpf.Controls">

    <Style TargetType="local:RatingControl">
        <Setter Property="Height" Value="32" />
        <!-- 9794813: retire these two properties as customisation points once all resource keys available -->
        <Setter Property="Foreground" Value="{DynamicResource RatingControlCaptionForeground}" />
        <Setter Property="UseSystemFocusVisuals" Value="{DynamicResource UseSystemFocusVisuals}" />
        <Setter Property="FocusVisualStyle" Value="{DynamicResource {x:Static SystemParameters.FocusVisualStyleKey}}" />
        <Setter Property="FontFamily" Value="{DynamicResource SymbolThemeFontFamily}" />
        <Setter Property="ItemInfo" Value="{DynamicResource RatingControlDefaultPathInfo}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:RatingControl">
                    <Grid x:Name="LayoutRoot">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <ui:VisualStateGroupListener.Listener>
                                    <ui:VisualStateGroupListener x:Name="CommonStatesListener" />
                                </ui:VisualStateGroupListener.Listener>
                                <VisualState x:Name="Disabled" />
                                <VisualState x:Name="Placeholder" />
                                <VisualState x:Name="PointerOverPlaceholder" />
                                <VisualState x:Name="PointerOverUnselected" />
                                <VisualState x:Name="Set" />
                                <VisualState x:Name="PointerOverSet" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>

                        <StackPanel
                            Orientation="Horizontal"
                            Grid.Row="0"
                            Margin="-20,-20,-20,-20">
                            <StackPanel
                                x:Name="RatingBackgroundStackPanel"
                                Orientation="Horizontal"
                                Background="Transparent"
                                Margin="20,20,0,20" />
                            <TextBlock x:Name="Caption" Height="32" Margin="4,9,20,0" Style="{DynamicResource CaptionTextBlockStyle}"
                                Foreground="{DynamicResource RatingControlCaptionForeground}" VerticalAlignment="Center" IsHitTestVisible="False"
                                AutomationProperties.Name="RatingCaption" Text="{TemplateBinding Caption}"/>
                            <!-- 4 = 8 item spacing +4 of magic redline spacing -8 to compensate for scale of the last RatingItem -->
                            <!--
                                NB: The redlines say 8px, but it's really 12 px because:
                                Designer note: The value between the last glyph and first text character is 12px.
                                (There's 4px of whitespace accounted for in the text area in the redline)
                            -->
                            <!-- TODO MSFT: 9925444 Fix vertical alignment in all text scenarios -->
                        </StackPanel>

                        <ContentPresenter
                            x:Name="ForegroundContentPresenter"
                            IsHitTestVisible="False"
                            Grid.Row="0">
                            <!-- Margin is on the StackPanel because ContentPresenter clips differently such that moving the reverse margin up won't work -->
                            <ContentPresenter.Content>
                                <StackPanel
                                    Orientation="Horizontal"
                                    Margin="-40,-40,-40,-40">
                                    <StackPanel
                                        x:Name="RatingForegroundStackPanel"
                                        Orientation="Horizontal"
                                        IsHitTestVisible="False"
                                        Margin="40,40,40,40" />
                                </StackPanel>
                            </ContentPresenter.Content>
                        </ContentPresenter>
                    </Grid>

                    <ControlTemplate.Triggers>
                        <!-- Disabled -->
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="Disabled">
                            <Setter TargetName="ForegroundContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource RatingControlDisabledSelectedForeground}" />
                        </Trigger>
                        <!-- Placeholder -->
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="Placeholder">
                            <Setter TargetName="ForegroundContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource RatingControlPlaceholderForeground}" />
                        </Trigger>
                        <!-- PointerOverPlaceholder -->
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="PointerOverPlaceholder">
                            <Setter TargetName="ForegroundContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource RatingControlPointerOverPlaceholderForeground}" />
                        </Trigger>
                        <!-- PointerOverUnselected -->
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="PointerOverUnselected">
                            <Setter TargetName="ForegroundContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource RatingControlPointerOverUnselectedForeground}" />
                        </Trigger>
                        <!-- Set -->
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="Set">
                            <Setter TargetName="ForegroundContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource RatingControlSelectedForeground}" />
                        </Trigger>
                        <!-- PointerOverSet -->
                        <Trigger SourceName="CommonStatesListener" Property="CurrentStateName" Value="PointerOverSet">
                            <Setter TargetName="ForegroundContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource RatingControlSelectedForeground}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>