<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/Resources/Default.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <!--  默认单选框  -->
    <Style x:Key="RubyerRadioButton" TargetType="{x:Type RadioButton}">
        <Setter Property="Background" Value="{DynamicResource ControlBackground}" />
        <Setter Property="BorderBrush" Value="{DynamicResource Border}" />
        <Setter Property="BorderThickness" Value="1.5" />
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}" />
        <Setter Property="Foreground" Value="{DynamicResource DefaultForeground}" />
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="bpa:ControlHelper.FocusBorderBrush" Value="{DynamicResource Primary}" />
        <Setter Property="bpa:ControlHelper.MouseOverBrush" Value="{DynamicResource Primary}" />
        <Setter Property="bpa:ControlHelper.CornerRadius" Value="{DynamicResource AllControlCornerRadius}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RadioButton}">
                    <Grid x:Name="templateRoot" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Border x:Name="radioButtonBorder"
                                Margin="0 0 1 0"
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                CornerRadius="{Binding ActualHeight, RelativeSource={RelativeSource Mode=Self}, Converter={StaticResource HalfOfDoubleConverter}}">
                            <bpa:Icon x:Name="littleDot"
                                      BorderBrush="Transparent"
                                      Foreground="{Binding Path=(bpa:ControlHelper.FocusBorderBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                      RenderTransformOrigin="0.5,0.5"
                                      Type="CheckboxBlankCircleFill">
                                <bpa:Icon.Width>
                                    <MultiBinding Converter="{StaticResource MathAddConverter}">
                                        <Binding Path="FontSize" RelativeSource="{RelativeSource Self}" />
                                        <Binding Source="2" />
                                    </MultiBinding>
                                </bpa:Icon.Width>
                                <bpa:Icon.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform ScaleX="0" ScaleY="0" />
                                        <SkewTransform />
                                        <RotateTransform />
                                        <TranslateTransform />
                                    </TransformGroup>
                                </bpa:Icon.RenderTransform>
                            </bpa:Icon>
                        </Border>

                        <ContentPresenter x:Name="contentPresenter"
                                          Grid.Column="1"
                                          Margin="{TemplateBinding Padding}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          Focusable="False"
                                          RecognizesAccessKey="True"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="HasContent" Value="True">
                            <Setter Property="Padding" Value="4 -1 0 0" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="contentPresenter" Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
                            <Setter TargetName="radioButtonBorder" Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
                        </Trigger>
                        <Trigger SourceName="radioButtonBorder" Property="IsMouseOver" Value="True">
                            <Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{Binding Path=(bpa:ControlHelper.MouseOverBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{Binding Path=(bpa:ControlHelper.FocusBorderBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
                        </Trigger>
                        <Trigger Property="IsChecked" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="littleDot"
                                                         Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
                                                         To="1"
                                                         Duration="0:0:0.25">
                                            <DoubleAnimation.EasingFunction>
                                                <BackEase EasingMode="EaseOut" />
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>
                                        <DoubleAnimation Storyboard.TargetName="littleDot"
                                                         Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
                                                         To="1"
                                                         Duration="0:0:0.25">
                                            <DoubleAnimation.EasingFunction>
                                                <BackEase EasingMode="EaseOut" />
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="littleDot"
                                                         Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
                                                         To="0"
                                                         Duration="0:0:0.25">
                                            <DoubleAnimation.EasingFunction>
                                                <BackEase EasingMode="EaseIn" />
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>
                                        <DoubleAnimation Storyboard.TargetName="littleDot"
                                                         Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
                                                         To="0"
                                                         Duration="0:0:0.25">
                                            <DoubleAnimation.EasingFunction>
                                                <BackEase EasingMode="EaseIn" />
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                            <Setter TargetName="radioButtonBorder" Property="BorderBrush" Value="{Binding Path=(bpa:ControlHelper.FocusBorderBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
                        </Trigger>
                        <Trigger Property="IsChecked" Value="{x:Null}">
                            <Setter TargetName="radioButtonBorder" Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--  亮色单选框  -->
    <Style x:Key="LightRadioButton"
           BasedOn="{StaticResource RubyerRadioButton}"
           TargetType="{x:Type RadioButton}">
        <Setter Property="bpa:ControlHelper.FocusBorderBrush" Value="{DynamicResource Light}" />
        <Setter Property="bpa:ControlHelper.MouseOverBrush" Value="{DynamicResource Light}" />
    </Style>

    <!--  暗色单选框  -->
    <Style x:Key="DarkRadioButton"
           BasedOn="{StaticResource RubyerRadioButton}"
           TargetType="{x:Type RadioButton}">
        <Setter Property="bpa:ControlHelper.FocusBorderBrush" Value="{DynamicResource Dark}" />
        <Setter Property="bpa:ControlHelper.MouseOverBrush" Value="{DynamicResource Dark}" />
    </Style>

    <!--  强调色单选框  -->
    <Style x:Key="AccentRadioButton"
           BasedOn="{StaticResource RubyerRadioButton}"
           TargetType="{x:Type RadioButton}">
        <Setter Property="bpa:ControlHelper.FocusBorderBrush" Value="{DynamicResource Accent}" />
        <Setter Property="bpa:ControlHelper.MouseOverBrush" Value="{DynamicResource Accent}" />
    </Style>
</ResourceDictionary>