<ResourceDictionary
    xmlns="https://github.com/avaloniaui"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:CompileBindings="True">
    <Design.PreviewWith>
        <Border Padding="20">
            <Calendar />
        </Border>
    </Design.PreviewWith>
    <ControlTheme x:Key="{x:Type Calendar}" TargetType="Calendar">
        <Setter Property="Foreground" Value="{DynamicResource CalendarForeground}" />
        <Setter Property="Background" Value="{DynamicResource CalendarBackground}" />
        <Setter Property="BorderBrush" Value="{DynamicResource CalendarBorderBrush}" />
        <Setter Property="BorderThickness" Value="{DynamicResource CalendarBorderThickness}" />
        <Setter Property="CornerRadius" Value="{DynamicResource CalendarCornerRadius}" />
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="Template">
            <ControlTemplate TargetType="Calendar">
                <StackPanel
                    Name="PART_Root"
                    HorizontalAlignment="Center"
                    ClipToBounds="True">
                    <CalendarItem
                        Name="PART_CalendarItem"
                        Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        CornerRadius="{TemplateBinding CornerRadius}"
                        HeaderBackground="{TemplateBinding HeaderBackground}" />
                </StackPanel>
            </ControlTemplate>
        </Setter>
    </ControlTheme>

    <ControlTheme x:Key="{x:Type CalendarItem}" TargetType="CalendarItem">
        <Setter Property="MinWidth" Value="{DynamicResource CalendarMinWidth}" />
        <Setter Property="MinHeight" Value="{DynamicResource CalendarMinHeight}" />
        <Setter Property="DayTitleTemplate">
            <Template>
                <TextBlock
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    x:DataType="x:String"
                    FontSize="{DynamicResource CalendarItemWeekDayNameFontSize}"
                    FontWeight="{DynamicResource CalendarItemWeekDayNameFontWeight}"
                    Foreground="{DynamicResource CalendarItemWeekDayNameForeground}"
                    Text="{Binding}" />
            </Template>
        </Setter>

        <Setter Property="Template">
            <ControlTemplate TargetType="CalendarItem">
                <Border
                    Padding="16"
                    Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    CornerRadius="{TemplateBinding CornerRadius}">
                    <Grid
                        MinWidth="{TemplateBinding MinWidth}"
                        MinHeight="{TemplateBinding MinHeight}"
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Stretch"
                        RowDefinitions="Auto,*">
                        <Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto">
                            <RepeatButton
                                Name="PART_PreviousButton"
                                Grid.Column="0"
                                Padding="0"
                                MinWidth="{Binding $self.MinHeight}"
                                Foreground="{TemplateBinding Foreground}"
                                Theme="{DynamicResource BorderlessRepeatButton}">
                                <PathIcon
                                    Theme="{DynamicResource InnerPathIcon}"
                                    Classes="Large"
                                    Data="{DynamicResource CalendarItemPreviousIconGlyph}"
                                    Foreground="{DynamicResource CalendarItemIconForeground}" />
                            </RepeatButton>

                            <Button
                                Name="PART_HeaderButton"
                                Grid.Column="1"
                                HorizontalContentAlignment="Center"
                                HorizontalAlignment="Stretch"
                                Foreground="{TemplateBinding Foreground}"
                                Theme="{DynamicResource BorderlessButton}" />

                            <RepeatButton
                                Name="PART_NextButton"
                                Grid.Column="2"
                                Padding="0"
                                MinWidth="{Binding $self.MinHeight}"
                                Foreground="{TemplateBinding Foreground}"
                                Theme="{DynamicResource BorderlessRepeatButton}">
                                <PathIcon
                                    Theme="{DynamicResource InnerPathIcon}"
                                    Classes="Large"
                                    Data="{DynamicResource CalendarItemNextIconGlyph}"
                                    Foreground="{DynamicResource CalendarItemIconForeground}" />
                            </RepeatButton>
                        </Grid>
                        <Grid
                            Name="PART_MonthView"
                            Grid.Row="1"
                            HorizontalAlignment="Stretch"
                            IsVisible="False"
                            ColumnDefinitions="*,*,*,*,*,*,*">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="{DynamicResource CalendarItemWeekDayNameHeight}" />
                                <RowDefinition Height="*" />
                                <RowDefinition Height="*" />
                                <RowDefinition Height="*" />
                                <RowDefinition Height="*" />
                                <RowDefinition Height="*" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                        </Grid>
                        <Grid
                            Name="PART_YearView"
                            Grid.Row="1"
                            Background="{TemplateBinding Background}"
                            IsVisible="False"
                            ColumnDefinitions="*,*,*,*"
                            RowDefinitions="*,*,*" />
                    </Grid>
                </Border>
            </ControlTemplate>
        </Setter>
    </ControlTheme>

    <ControlTheme x:Key="{x:Type CalendarButton}" TargetType="CalendarButton">
        <Setter Property="ClickMode" Value="Release" />
        <Setter Property="Margin" Value="2" />
        <Setter Property="Foreground" Value="{DynamicResource CalendarItemCalendarButtonForeground}" />
        <Setter Property="Background" Value="{DynamicResource CalendarItemCalendarButtonBackground}" />
        <Setter Property="BorderBrush" Value="{DynamicResource CalendarItemCalendarButtonBorderBrush}" />
        <Setter Property="CornerRadius" Value="{DynamicResource CalendarItemCalendarButtonCornerRadius}" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="ClipToBounds" Value="False" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="Template">
            <ControlTemplate TargetType="CalendarButton">
                <ContentControl
                    Name="Content"
                    Margin="{TemplateBinding Padding}"
                    HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                    VerticalAlignment="{TemplateBinding VerticalAlignment}"
                    HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                    VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                    Background="{TemplateBinding Background}"
                    Content="{TemplateBinding Content}"
                    ContentTemplate="{TemplateBinding ContentTemplate}"
                    CornerRadius="{TemplateBinding CornerRadius}"
                    FontSize="{TemplateBinding FontSize}" />
            </ControlTemplate>
        </Setter>

        <Style Selector="^:pointerover /template/ ContentControl">
            <Setter Property="Background" Value="{DynamicResource CalendarItemCalendarButtonPointeroverBackground}" />
        </Style>

        <Style Selector="^:pressed /template/ ContentControl">
            <Setter Property="Background" Value="{DynamicResource CalendarItemCalendarButtonPressedBackground}" />
        </Style>

        <Style Selector="^:selected">
            <Style Selector="^ /template/ ContentControl">
                <Setter Property="Background" Value="{DynamicResource CalendarItemCalendarButtonSelectedBackground}" />
                <Setter Property="Foreground" Value="{DynamicResource CalendarItemCalendarButtonSelectedForeground}" />
                <Setter Property="FontWeight" Value="{DynamicResource CalendarItemCalendarButtonSelectedFontWeight}" />
            </Style>
        </Style>

        <Style Selector="^:blackout /template/ ContentControl">
            <Setter Property="Foreground" Value="{DynamicResource CalendarItemCalendarButtonBlackoutForeground}" />
        </Style>

        <Style Selector="^:disabled /template/ ContentControl">
            <Setter Property="Foreground" Value="{DynamicResource CalendarItemCalendarButtonDisabledForeground}" />
        </Style>

        <Style Selector="^:inactive /template/ ContentControl">
            <Setter Property="Foreground" Value="{DynamicResource CalendarItemCalendarButtonInactiveForeground}" />
        </Style>
    </ControlTheme>

    <ControlTheme x:Key="{x:Type CalendarDayButton}" TargetType="CalendarDayButton">
        <Setter Property="ClickMode" Value="Release" />
        <Setter Property="Margin" Value="2" />
        <Setter Property="Padding" Value="4" />
        <Setter Property="Foreground" Value="{DynamicResource CalendarItemCalendarDayButtonForeground}" />
        <Setter Property="Background" Value="{DynamicResource CalendarItemCalendarDayButtonBackground}" />
        <Setter Property="CornerRadius" Value="{DynamicResource CalendarItemCalendarDayButtonCornerRadius}" />
        <Setter Property="BorderBrush" Value="{DynamicResource CalendarItemCalendarDayButtonBorderBrush}" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="ClipToBounds" Value="False" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="Template">
            <ControlTemplate TargetType="CalendarDayButton">
                <ContentControl
                    Name="Content"
                    Padding="{TemplateBinding Padding}"
                    HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                    VerticalAlignment="{TemplateBinding VerticalAlignment}"
                    HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                    VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                    Background="{TemplateBinding Background}"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"
                    Content="{TemplateBinding Content}"
                    ContentTemplate="{TemplateBinding ContentTemplate}"
                    CornerRadius="{TemplateBinding CornerRadius}"
                    FontSize="{TemplateBinding FontSize}" />
            </ControlTemplate>
        </Setter>

        <Style Selector="^:pointerover /template/ ContentControl">
            <Setter Property="Background" Value="{DynamicResource CalendarItemCalendarDayButtonPointeroverBackground}" />
        </Style>

        <Style Selector="^:pressed /template/ ContentControl">
            <Setter Property="Background" Value="{DynamicResource CalendarItemCalendarDayButtonPressedBackground}" />
        </Style>

        <Style Selector="^:today /template/ ContentControl">
            <Setter Property="Background" Value="{DynamicResource CalendarItemCalendarDayButtonTodayBackground}" />
            <Setter Property="Foreground" Value="{DynamicResource CalendarItemCalendarDayButtonTodayForeground}" />
        </Style>

        <Style Selector="^:selected /template/ ContentControl">
            <Setter Property="Background" Value="{DynamicResource CalendarItemCalendarDayButtonSelectedBackground}" />
            <Setter Property="Foreground" Value="{DynamicResource CalendarItemCalendarDayButtonSelectedForeground}" />
        </Style>

        <Style Selector="^:inactive /template/ ContentControl">
            <Setter Property="Foreground" Value="{DynamicResource CalendarItemCalendarDayButtonInactiveForeground}" />
        </Style>

        <Style Selector="^:blackout /template/ ContentControl">
            <Setter Property="Foreground" Value="{DynamicResource CalendarItemCalendarDayButtonBlackoutForeground}" />
        </Style>

        <Style Selector="^:disabled /template/ ContentControl">
            <Setter Property="Foreground" Value="{DynamicResource CalendarItemCalendarDayButtonDisabledForeground}" />
        </Style>
    </ControlTheme>
</ResourceDictionary>