<Page x:Class="CalendarDemo.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="696"
    xmlns:c1="using:C1.Xaml"
    xmlns:local="using:CalendarDemo"
    xmlns:c1calendar="using:C1.Xaml.Calendar">
    <Page.Resources>
        <!-- return custom DataTemplates for calendar days -->
        <local:DaySlotTemplateSelector x:Key="DaySlotTemplateSelector">
            <c1calendar:DaySlotTemplateSelector.Resources>
                <ResourceDictionary>
                    <DataTemplate x:Key="BoldedDay">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <!-- show appointments information saved in the DaySlot.DataSource property -->
                            <TextBlock Grid.Row="0" Text="{Binding Path=DataSource[0].Subject}" FontSize="10" Height="22" TextWrapping="Wrap"/>
                            <TextBlock Text="{Binding}" Grid.Row="1" 
                                       Foreground="Plum" HorizontalAlignment="Left" VerticalAlignment="Bottom" FontWeight="SemiBold" Margin="6,0,0,4"/>
                        </Grid>
                    </DataTemplate>
                    <DataTemplate x:Key="UnboldedDay">
                        <TextBlock Text="{Binding}" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="6,22,0,4"/>
                    </DataTemplate>
                </ResourceDictionary>
            </c1calendar:DaySlotTemplateSelector.Resources>
        </local:DaySlotTemplateSelector>

    </Page.Resources>

    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition />
        </Grid.RowDefinitions>

        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12, 0, 12, 6">
            <TextBlock x:Name="ApplicationTitle" Text="C1Calendar Demo" FontSize="{StaticResource TextStyleLargeFontSize}"/>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="SelectedDate: " FontSize="{StaticResource TextStyleMediumFontSize}"/>
                <TextBlock Text="{Binding SelectedDate, ElementName=cal1}" FontSize="{StaticResource TextStyleMediumFontSize}"/>
            </StackPanel>
        </StackPanel>

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="2">
            <c1calendar:C1Calendar x:Name="cal1" MaxSelectionCount="14" WeekendBrush="LightGreen" MaxHeight="600"
                                   Loaded="cal1_Loaded" DoubleTapped="cal1_DoubleTapped"
                                   DisplayDateChanging="cal1_DisplayDateChanging" />
        </Grid>
    </Grid>

    <Page.BottomAppBar>
        <CommandBar>
            <CommandBar.PrimaryCommands>
                <AppBarButton Icon="Switch"  Label="Alter" Click="AlterAppearance_Click"/>
                <AppBarButton Icon="Home" Label="Today" Click="Today_Click"/>
                <AppBarButton Icon="Help" Label="Help" Click="Help_Click"/>
            </CommandBar.PrimaryCommands>
         </CommandBar>
    </Page.BottomAppBar>
</Page>