<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="RubyerCheckBox" TargetType="{x:Type CheckBox}">
        <Setter Property="Background" Value="{DynamicResource ControlBackground}" />
        <Setter Property="BorderBrush" Value="{StaticResource 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="Bottom" />
        <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="bpa:ToggleButtonHelper.CheckedContent" Value="{x:Null}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CheckBox}">
                    <Grid x:Name="templateRoot"
                          Background="Transparent"
                          SnapsToDevicePixels="True">
                        <Grid.Height>
                            <MultiBinding Converter="{StaticResource MathAddConverter}">
                                <Binding Path="FontSize" RelativeSource="{RelativeSource AncestorType=CheckBox}" />
                                <Binding Source="5" />
                            </MultiBinding>
                        </Grid.Height>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <Grid x:Name="checkBoxGrid"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                            <Border x:Name="checkBoxBorder"
                                    Background="{TemplateBinding Background}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}" />

                            <bpa:Transition IsShow="{TemplateBinding IsChecked}">
                                <Border x:Name="backBorder"
                                        Background="{Binding Path=(bpa:ControlHelper.FocusBorderBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                        CornerRadius="{Binding Path=(bpa:ControlHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
                            </bpa:Transition>

                            <Grid x:Name="markGrid" Width="{Binding ActualHeight, RelativeSource={RelativeSource Self}}">
                                <bpa:Icon x:Name="checkedMark"
                                          Foreground="{DynamicResource WhiteForeground}"
                                          RenderTransformOrigin="0.5,0.5"
                                          Type="CheckFill">
                                    <bpa:Icon.RenderTransform>
                                        <TransformGroup>
                                            <ScaleTransform ScaleX="0" ScaleY="0" />
                                            <SkewTransform />
                                            <RotateTransform />
                                            <TranslateTransform />
                                        </TransformGroup>
                                    </bpa:Icon.RenderTransform>
                                </bpa:Icon>

                                <bpa:Icon x:Name="nullMark"
                                          Foreground="{DynamicResource WhiteForeground}"
                                          RenderTransformOrigin="0.5,0.5"
                                          Type="SubtractLine"
                                          Visibility="Collapsed" />
                            </Grid>
                        </Grid>

                        <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="FocusVisualStyle" Value="{StaticResource FocusVisual}" />-->
                            <Setter Property="Padding" Value="4 -1 0 0" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="templateRoot" Property="Opacity" Value="{DynamicResource UnenableOpcity}" />
                        </Trigger>
                        <Trigger SourceName="checkBoxGrid" Property="IsMouseOver" Value="True">
                            <Setter TargetName="checkBoxBorder" Property="BorderBrush" Value="{Binding Path=(bpa:ControlHelper.MouseOverBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="checkBoxBorder" Property="BorderBrush" Value="{Binding Path=(bpa:ControlHelper.FocusBorderBrush), RelativeSource={RelativeSource Mode=TemplatedParent}}" />
                        </Trigger>
                        <Trigger Property="IsChecked" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="checkedMark" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                                            <EasingDoubleKeyFrame KeyTime="0:0:0.15" Value="0" />
                                            <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1">
                                                <EasingDoubleKeyFrame.EasingFunction>
                                                    <CubicEase EasingMode="EaseOut" />
                                                </EasingDoubleKeyFrame.EasingFunction>
                                            </EasingDoubleKeyFrame>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="checkedMark" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                                            <EasingDoubleKeyFrame KeyTime="0:0:0.15" Value="0" />
                                            <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1">
                                                <EasingDoubleKeyFrame.EasingFunction>
                                                    <CubicEase EasingMode="EaseOut" />
                                                </EasingDoubleKeyFrame.EasingFunction>
                                            </EasingDoubleKeyFrame>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="checkedMark"
                                                         Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
                                                         To="0"
                                                         Duration="0:0:0.2">
                                            <DoubleAnimation.EasingFunction>
                                                <BackEase EasingMode="EaseOut" />
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>
                                        <DoubleAnimation Storyboard.TargetName="checkedMark"
                                                         Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
                                                         To="0"
                                                         Duration="0:0:0.2">
                                            <DoubleAnimation.EasingFunction>
                                                <BackEase EasingMode="EaseOut" />
                                            </DoubleAnimation.EasingFunction>
                                        </DoubleAnimation>
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsChecked" Value="{x:Null}">
                            <Setter TargetName="checkedMark" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="nullMark" Property="Visibility" Value="Visible" />
                            <Setter TargetName="backBorder" Property="Opacity" Value="1" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--  亮色多选框  -->
    <Style x:Key="LightCheckBox"
           BasedOn="{StaticResource RubyerCheckBox}"
           TargetType="{x:Type CheckBox}">
        <Setter Property="bpa:ControlHelper.FocusBorderBrush" Value="{DynamicResource Light}" />
        <Setter Property="bpa:ControlHelper.MouseOverBrush" Value="{DynamicResource Light}" />
    </Style>

    <!--  暗色多选框  -->
    <Style x:Key="DarkCheckBox"
           BasedOn="{StaticResource RubyerCheckBox}"
           TargetType="{x:Type CheckBox}">
        <Setter Property="bpa:ControlHelper.FocusBorderBrush" Value="{DynamicResource Dark}" />
        <Setter Property="bpa:ControlHelper.MouseOverBrush" Value="{DynamicResource Dark}" />
    </Style>

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