<ResourceDictionary
    x:ClassModifier="internal"
    xmlns="https://github.com/avaloniaui"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <ControlTheme TargetType="CheckBox" x:Key="{x:Type CheckBox}">
        <Setter Property="Padding" Value="4" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Template">
            <ControlTemplate TargetType="{x:Type CheckBox}">
                <Border
                    Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    CornerRadius="{TemplateBinding CornerRadius}"
                    Name="border"
                    Padding="{TemplateBinding Padding}">
                    <StackPanel Orientation="Horizontal">
                        <Decorator
                            HorizontalAlignment="Center"
                            Margin="{TemplateBinding Padding}"
                            VerticalAlignment="Center">

                            <Canvas Height="20" Width="20">
                                <Image
                                    Height="18"
                                    IsVisible="False"
                                    Source="{StaticResource SquareCheckImage}"
                                    Width="18"
                                    x:Name="TickMark" />

                                <Image
                                    Height="18"
                                    IsVisible="False"
                                    Source="{StaticResource SquareImage}"
                                    Stretch="Fill"
                                    Width="18"
                                    x:Name="indeterminateMark" />

                                <Image
                                    Height="18"
                                    IsVisible="False"
                                    Source="{StaticResource SquareXImage}"
                                    Stretch="Fill"
                                    Width="18"
                                    x:Name="CrossMark" />
                            </Canvas>
                        </Decorator>
                        <ContentPresenter
                            Content="{TemplateBinding Content}"
                            ContentTemplate="{TemplateBinding ContentTemplate}"
                            HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                            Name="PART_ContentPresenter"
                            RecognizesAccessKey="True"
                            TextElement.Foreground="{TemplateBinding Foreground}"
                            VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
                    </StackPanel>
                </Border>
            </ControlTemplate>
        </Setter>

        <Style Selector="^:checked">
            <Style Selector="^ /template/ Image#TickMark">
                <Setter Property="IsVisible" Value="True" />
            </Style>
            <Style Selector="^ /template/ Image#CrossMark">
                <Setter Property="IsVisible" Value="False" />
            </Style>
            <Style Selector="^ /template/ Image#indeterminateMark">
                <Setter Property="IsVisible" Value="False" />
            </Style>
        </Style>

        <Style Selector="^:unchecked">
            <Style Selector="^ /template/ Image#TickMark">
                <Setter Property="IsVisible" Value="False" />
            </Style>
            <Style Selector="^ /template/ Image#CrossMark">
                <Setter Property="IsVisible" Value="True" />
            </Style>
            <Style Selector="^ /template/ Image#indeterminateMark">
                <Setter Property="IsVisible" Value="False" />
            </Style>
        </Style>

        <Style Selector="^:indeterminate">
            <Style Selector="^ /template/ Image#TickMark">
                <Setter Property="IsVisible" Value="False" />
            </Style>
            <Style Selector="^ /template/ Image#CrossMark">
                <Setter Property="IsVisible" Value="False" />
            </Style>
            <Style Selector="^ /template/ Image#indeterminateMark">
                <Setter Property="IsVisible" Value="True" />
            </Style>
        </Style>

        <Style Selector="^.hover:pointerover /template/ Border#border">
            <Style.Animations>
                <Animation Duration="{StaticResource ButtonHoverAnimationDuration}" IterationCount="1">
                    <KeyFrame>
                        <Setter Property="Background">
                            <SolidColorBrush Color="{DynamicResource SecondaryBackgroundColor}" />
                        </Setter>
                    </KeyFrame>
                    <KeyFrame Cue="1">
                        <Setter Property="Background">
                            <SolidColorBrush Color="{DynamicResource AccentColor}" />
                        </Setter>
                    </KeyFrame>
                </Animation>
            </Style.Animations>
            <Setter Property="Background" Value="{DynamicResource AccentColor}" />
        </Style>
        <Style Selector="^.altHover:pointerover /template/ Border#border">
            <Style.Animations>
                <Animation Duration="{StaticResource ButtonHoverAnimationDuration}" IterationCount="1">
                    <KeyFrame>
                        <Setter Property="Background">
                            <SolidColorBrush Color="{DynamicResource SecondaryBackgroundColor}" />
                        </Setter>
                        <Setter Property="BorderBrush">
                            <SolidColorBrush Color="{DynamicResource OuterBorderColor}" />
                        </Setter>
                    </KeyFrame>
                    <KeyFrame Cue="1">
                        <Setter Property="Background">
                            <SolidColorBrush Color="{DynamicResource AltBackgroundHoverColor}" />
                        </Setter>
                        <Setter Property="BorderBrush">
                            <SolidColorBrush Color="{DynamicResource SecondaryBorderColor}" />
                        </Setter>
                    </KeyFrame>
                </Animation>
            </Style.Animations>
            <Setter Property="Background" Value="{DynamicResource AltBackgroundHoverColor}" />
            <Setter Property="BorderBrush" Value="{DynamicResource SecondaryBorderColor}" />
        </Style>
        <Style Selector="^.noBorderHover:pointerover /template/ Border#border">
            <Style.Animations>
                <Animation Duration="{StaticResource ButtonHoverAnimationDuration}" IterationCount="1">
                    <KeyFrame>
                        <Setter Property="Background">
                            <SolidColorBrush Color="Transparent" />
                        </Setter>
                    </KeyFrame>
                    <KeyFrame Cue="1">
                        <Setter Property="Background">
                            <SolidColorBrush Color="{DynamicResource AltBackgroundHoverColor}" />
                        </Setter>
                    </KeyFrame>
                </Animation>
            </Style.Animations>
            <Setter Property="Background" Value="{DynamicResource AltBackgroundHoverColor}" />
        </Style>
        <Style Selector="^.hover:pressed  /template/ ContentPresenter#PART_ContentPresenter">
            <Setter Property="Background" Value="{DynamicResource SecondaryAccentColor}" />
        </Style>
        <Style Selector="^.noBorderHover:pressed  /template/ ContentPresenter#PART_ContentPresenter">
            <Setter Property="Background" Value="{DynamicResource SecondaryAccentColor}" />
        </Style>
        <Style Selector="^:disabled">
            <Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}" />
        </Style>

        <Style Selector="^.changeColor  /template/ Image#TickMark">
            <Setter Property="Source" Value="{StaticResource SquareCheckAltImage}" />
        </Style>
        <Style Selector="^.changeColor  /template/ Image#CrossMark">
            <Setter Property="Source" Value="{StaticResource SquareXAltImage}" />
        </Style>
        <Style Selector="^.changeColor  /template/ Image#indeterminateMark">
            <Setter Property="Source" Value="{StaticResource SquareAltImage}" />
        </Style>

    </ControlTheme>
</ResourceDictionary>