<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:RodelAgent.UI.Controls">

    <ResourceDictionary.MergedDictionaries>
        <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
    </ResourceDictionary.MergedDictionaries>

    <ResourceDictionary.ThemeDictionaries>
        <ResourceDictionary x:Key="Light">
            <x:Double x:Key="CardPanelStrokeThickness">0</x:Double>
        </ResourceDictionary>
        <ResourceDictionary x:Key="Dark">
            <x:Double x:Key="CardPanelStrokeThickness">0</x:Double>
        </ResourceDictionary>
        <ResourceDictionary x:Key="HighContrast">
            <x:Double x:Key="CardPanelStrokeThickness">1</x:Double>
        </ResourceDictionary>
    </ResourceDictionary.ThemeDictionaries>

    <Style x:Key="DefaultCardPanelStyle" TargetType="local:CardPanel">
        <Setter Property="Background" Value="{ThemeResource CardBackgroundFillColorDefaultBrush}" />
        <Setter Property="StrokeThickness" Value="{ThemeResource CardPanelStrokeThickness}" />
        <Setter Property="BorderBrush" Value="{ThemeResource CardStrokeColorDefaultBrush}" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="Foreground" Value="{ThemeResource TextFillColorSecondaryBrush}" />
        <Setter Property="CornerRadius" Value="{StaticResource ControlCornerRadius}" />
        <Setter Property="PointerOverBackground" Value="{ThemeResource SubtleFillColorSecondaryBrush}" />
        <Setter Property="PointerOverBorderBrush" Value="{ThemeResource DividerStrokeColorDefaultBrush}" />
        <Setter Property="PressedBackground" Value="{ThemeResource CardBackgroundFillColorSecondaryBrush}" />
        <Setter Property="PressedBorderBrush" Value="{ThemeResource SubtleFillColorTransparentBrush}" />
        <Setter Property="DisabledBackground" Value="{ThemeResource ControlFillColorDisabledBrush}" />
        <Setter Property="DisabledBorderBrush" Value="{ThemeResource ControlStrokeColorSecondaryBrush}" />
        <Setter Property="CheckedBorderBrush" Value="{ThemeResource AccentButtonBorderBrush}" />
        <Setter Property="CheckedBackground" Value="{ThemeResource SubtleFillColorSecondaryBrush}" />
        <Setter Property="CheckedForeground" Value="{ThemeResource TextFillColorPrimaryBrush}" />
        <Setter Property="CheckedPointerOverBackground" Value="{ThemeResource SubtleFillColorTertiaryBrush}" />
        <Setter Property="CheckedPointerOverBorderBrush" Value="{ThemeResource AccentButtonBorderBrushPointerOver}" />
        <Setter Property="CheckedPointerOverForeground" Value="{ThemeResource TextFillColorPrimaryBrush}" />
        <Setter Property="CheckedPressedBackground" Value="{ThemeResource SubtleFillColorSecondaryBrush}" />
        <Setter Property="CheckedPressedBorderBrush" Value="{ThemeResource AccentButtonBorderBrushPressed}" />
        <Setter Property="CheckedPressedForeground" Value="{ThemeResource TextFillColorPrimaryBrush}" />
        <Setter Property="CheckedDisabledBackground" Value="{ThemeResource ControlFillColorDisabledBrush}" />
        <Setter Property="CheckedDisabledBorderBrush" Value="{ThemeResource AccentButtonBorderBrushDisabled}" />
        <Setter Property="CheckedDisabledForeground" Value="{ThemeResource TextFillColorDisabledBrush}" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="UseSystemFocusVisuals" Value="True" />
        <Setter Property="FocusVisualMargin" Value="-3" />
        <Setter Property="FocusVisualPrimaryThickness" Value="2" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:CardPanel">
                    <Grid x:Name="RootContainer" TabFocusNavigation="Once">
                        <Rectangle
                            x:Name="HostContainer"
                            Fill="{TemplateBinding Background}"
                            RadiusX="4"
                            RadiusY="4"
                            Stroke="{TemplateBinding BorderBrush}"
                            StrokeThickness="{TemplateBinding StrokeThickness}" />
                        <ContentPresenter
                            x:Name="ContentPresenter"
                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                            HorizontalContentAlignment="Stretch"
                            VerticalContentAlignment="Stretch"
                            Canvas.ZIndex="1"
                            Content="{TemplateBinding Content}"
                            ContentTemplate="{TemplateBinding ContentTemplate}" />
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />

                                <VisualState x:Name="PointerOver">
                                    <VisualState.Storyboard>
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HostContainer" Storyboard.TargetProperty="Fill">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Path=PointerOverBackground, RelativeSource={RelativeSource Mode=TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextFillColorPrimaryBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HostContainer" Storyboard.TargetProperty="Stroke">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Path=PointerOverBorderBrush, RelativeSource={RelativeSource Mode=TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState.Storyboard>
                                </VisualState>

                                <VisualState x:Name="Pressed">
                                    <VisualState.Storyboard>
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HostContainer" Storyboard.TargetProperty="Fill">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Path=PressedBackground, RelativeSource={RelativeSource Mode=TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HostContainer" Storyboard.TargetProperty="Stroke">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Path=PressedBorderBrush, RelativeSource={RelativeSource Mode=TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState.Storyboard>
                                </VisualState>

                                <VisualState x:Name="Disabled">
                                    <VisualState.Storyboard>
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HostContainer" Storyboard.TargetProperty="Fill">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Path=DisabledBackground, RelativeSource={RelativeSource Mode=TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HostContainer" Storyboard.TargetProperty="Stroke">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Path=DisabledBorderBrush, RelativeSource={RelativeSource Mode=TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState.Storyboard>
                                </VisualState>

                                <VisualState x:Name="Checked">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HostContainer" Storyboard.TargetProperty="Fill">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Path=CheckedBackground, RelativeSource={RelativeSource Mode=TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Path=CheckedForeground, RelativeSource={RelativeSource Mode=TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HostContainer" Storyboard.TargetProperty="Stroke">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Path=CheckedBorderBrush, RelativeSource={RelativeSource Mode=TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="CheckedPointerOver">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HostContainer" Storyboard.TargetProperty="Fill">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Path=CheckedPointerOverBackground, RelativeSource={RelativeSource Mode=TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Path=CheckedPointerOverForeground, RelativeSource={RelativeSource Mode=TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HostContainer" Storyboard.TargetProperty="Stroke">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Path=CheckedPointerOverBorderBrush, RelativeSource={RelativeSource Mode=TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="CheckedPressed">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HostContainer" Storyboard.TargetProperty="Fill">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Path=CheckedPressedBackground, RelativeSource={RelativeSource Mode=TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Path=CheckedPressedForeground, RelativeSource={RelativeSource Mode=TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HostContainer" Storyboard.TargetProperty="Stroke">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Path=CheckedPressedBorderBrush, RelativeSource={RelativeSource Mode=TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="CheckedDisabled">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HostContainer" Storyboard.TargetProperty="Fill">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Path=CheckedDisabledBackground, RelativeSource={RelativeSource Mode=TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Path=CheckedDisabledForeground, RelativeSource={RelativeSource Mode=TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" />
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HostContainer" Storyboard.TargetProperty="Stroke">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Path=CheckedDisabledBorderBrush, RelativeSource={RelativeSource Mode=TemplatedParent}, UpdateSourceTrigger=PropertyChanged}" />
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style BasedOn="{StaticResource DefaultCardPanelStyle}" TargetType="local:CardPanel" />
</ResourceDictionary>
