<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:c1="using:C1.Xaml"
    xmlns:c1tile="using:C1.Xaml.Tile">


    <c1tile:MultiplyConverter x:Key="MultiplyConverter"/>

    <Style x:Key="HeaderStyle" TargetType="ContentControl">
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Top"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ContentControl">
                    <Border Background="{TemplateBinding Background}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                        <ContentPresenter Content="{TemplateBinding Content}"
                                          ContentTemplate="{TemplateBinding ContentTemplate}"
                                          Margin="{TemplateBinding Padding}"
                                          ContentTransitions="{TemplateBinding ContentTransitions}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <Style  x:Key="C1TileBaseStyle" TargetType="c1tile:C1TileBase">
        <Setter Property="Background" Value="{ThemeResource ButtonBackgroundThemeBrush}" />
        <Setter Property="Foreground" Value="{ThemeResource ButtonForegroundThemeBrush}"/>
        <Setter Property="BorderBrush" Value="{ThemeResource ButtonBorderThemeBrush}" />
        <Setter Property="BorderThickness" Value="{ThemeResource ButtonBorderThemeThickness}" />
        <Setter Property="Padding" Value="12,4,12,4" />
        <Setter Property="Width" Value="150" />
        <Setter Property="Height" Value="150" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
        <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
        <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
        <Setter Property="VerticalHeaderAlignment" Value="Bottom"/>
        <Setter Property="HorizontalHeaderAlignment" Value="Left"/>
        <Setter Property="HeaderForeground" Value="{ThemeResource ApplicationForegroundThemeBrush}"/>
        <Setter Property="HeaderFontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
        <Setter Property="HeaderFontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
        <Setter Property="HeaderPadding" Value="12,4,12,4" />
    </Style>

    <Style TargetType="c1tile:C1Tile" BasedOn="{StaticResource C1TileBaseStyle}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="c1tile:C1Tile">
                    <Grid x:Name="LayoutRoot" >
                        <Grid.Resources>
                            <ResourceDictionary>
                                <Storyboard x:Key="ContentChangeAnimation" FillBehavior="Stop">
                                    <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BackContentPresenter" Storyboard.TargetProperty="(RenderTransform).Y"
                                                               Duration="0:0:1.1">
                                        <LinearDoubleKeyFrame KeyTime="0:0:1" Value="{Binding Height, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource MultiplyConverter}, ConverterParameter=-1}"/>
                                        <DiscreteDoubleKeyFrame KeyTime="0:0:1.1" Value="{Binding Height, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource MultiplyConverter}, ConverterParameter=-2}" />
                                    </DoubleAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackContentPresenter" Storyboard.TargetProperty="Visibility"
                                                               Duration="0:0:1" FillBehavior="Stop">
                                        <ObjectAnimationUsingKeyFrames.KeyFrames>
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames.KeyFrames>
                                    </ObjectAnimationUsingKeyFrames>
                                    <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="(RenderTransform).Y"
                                                               Duration="0:0:1">
                                        <DiscreteDoubleKeyFrame KeyTime="0" Value="{Binding Height, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource MultiplyConverter}, ConverterParameter=1}"/>
                                        <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0" />
                                    </DoubleAnimationUsingKeyFrames>
                                </Storyboard>
                            </ResourceDictionary>
                        </Grid.Resources>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="contentGrid"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0"
                                                         To="{ThemeResource ListViewItemDisabledThemeOpacity}" />
                                        </Storyboard>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid x:Name="contentGrid" Background="{TemplateBinding Background}" >
                            <ContentPresenter x:Name="BackContentPresenter" Margin="{TemplateBinding Padding}" 
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                              Visibility="Collapsed">
                                <ContentPresenter.RenderTransform>
                                    <TranslateTransform/>
                                </ContentPresenter.RenderTransform>
                            </ContentPresenter>
                            <ContentPresenter x:Name="ContentPresenter" Margin="{TemplateBinding Padding}" 
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                                <ContentPresenter.RenderTransform>
                                    <TranslateTransform/>
                                </ContentPresenter.RenderTransform>
                            </ContentPresenter>
                            <ContentControl IsTabStop="False" Margin="{TemplateBinding Padding}" 
                                            Style="{StaticResource HeaderStyle}"
                                                ContentTemplate="{TemplateBinding HeaderTemplate}"
                                                Content="{TemplateBinding Header}"
                                                Padding="{TemplateBinding HeaderPadding}" 
                                                FontFamily="{TemplateBinding HeaderFontFamily}" 
                                                FontSize="{TemplateBinding HeaderFontSize}" 
                                                Background="{TemplateBinding HeaderBackground}"
                                                Foreground="{TemplateBinding HeaderForeground}" 
                                                HorizontalContentAlignment="{TemplateBinding HorizontalHeaderAlignment}" 
                                                VerticalAlignment="{TemplateBinding VerticalHeaderAlignment}" />
                            <Border  
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"/>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="c1tile:C1SlideTile" BasedOn="{StaticResource C1TileBaseStyle}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="c1tile:C1SlideTile">
                    <Grid x:Name="LayoutRoot" >
                        <Grid.Resources>
                            <ResourceDictionary>
                                <Storyboard x:Name="ContentChangeAnimationUp" FillBehavior="Stop">
                                    <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BackContentPresenter" Storyboard.TargetProperty="(RenderTransform).Y"
                                                               Duration="0:0:1.1">
                                        <LinearDoubleKeyFrame KeyTime="0:0:1" Value="{Binding Height, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource MultiplyConverter}, ConverterParameter=-1}"/>
                                        <DiscreteDoubleKeyFrame KeyTime="0:0:1.1" Value="{Binding Height, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource MultiplyConverter}, ConverterParameter=-2}" />
                                    </DoubleAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackContentPresenter" Storyboard.TargetProperty="Visibility"
                                                               Duration="0:0:1" FillBehavior="Stop">
                                        <ObjectAnimationUsingKeyFrames.KeyFrames>
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames.KeyFrames>
                                    </ObjectAnimationUsingKeyFrames>
                                    <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="(RenderTransform).Y"
                                                               Duration="0:0:1">
                                        <DiscreteDoubleKeyFrame KeyTime="0" Value="{Binding Height, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource MultiplyConverter}, ConverterParameter=1}"/>
                                        <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0" />
                                    </DoubleAnimationUsingKeyFrames>
                                </Storyboard>
                                <Storyboard x:Name="ContentChangeAnimationLeft" FillBehavior="Stop">
                                    <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BackContentPresenter" Storyboard.TargetProperty="(RenderTransform).X"
                                                               Duration="0:0:1.1">
                                        <LinearDoubleKeyFrame KeyTime="0:0:1" Value="{Binding Width, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource MultiplyConverter}, ConverterParameter=-1}"/>
                                        <DiscreteDoubleKeyFrame KeyTime="0:0:1.1" Value="{Binding Width, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource MultiplyConverter}, ConverterParameter=-2}" />
                                    </DoubleAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackContentPresenter" Storyboard.TargetProperty="Visibility"
                                                               Duration="0:0:1" FillBehavior="Stop">
                                        <ObjectAnimationUsingKeyFrames.KeyFrames>
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames.KeyFrames>
                                    </ObjectAnimationUsingKeyFrames>
                                    <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="(RenderTransform).X"
                                                               Duration="0:0:1">
                                        <DiscreteDoubleKeyFrame KeyTime="0" Value="{Binding Width, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource MultiplyConverter}, ConverterParameter=1}"/>
                                        <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0" />
                                    </DoubleAnimationUsingKeyFrames>
                                </Storyboard>
                                <Storyboard x:Name="ContentChangeAnimationDown" FillBehavior="Stop">
                                    <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BackContentPresenter" Storyboard.TargetProperty="(RenderTransform).Y"
                                                               Duration="0:0:1.1">
                                        <LinearDoubleKeyFrame KeyTime="0:0:1" Value="{Binding Height, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource MultiplyConverter}, ConverterParameter=1}"/>
                                        <DiscreteDoubleKeyFrame KeyTime="0:0:1.1" Value="{Binding Height, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource MultiplyConverter}, ConverterParameter=2}" />
                                    </DoubleAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackContentPresenter" Storyboard.TargetProperty="Visibility"
                                                               Duration="0:0:1" FillBehavior="Stop">
                                        <ObjectAnimationUsingKeyFrames.KeyFrames>
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames.KeyFrames>
                                    </ObjectAnimationUsingKeyFrames>
                                    <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="(RenderTransform).Y"
                                                               Duration="0:0:1">
                                        <DiscreteDoubleKeyFrame KeyTime="0" Value="{Binding Height, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource MultiplyConverter}, ConverterParameter=-1}"/>
                                        <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0" />
                                    </DoubleAnimationUsingKeyFrames>
                                </Storyboard>
                                <Storyboard x:Name="ContentChangeAnimationRight" FillBehavior="Stop">
                                    <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BackContentPresenter" Storyboard.TargetProperty="(RenderTransform).X"
                                                               Duration="0:0:1.1">
                                        <LinearDoubleKeyFrame KeyTime="0:0:1" Value="{Binding Width, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource MultiplyConverter}, ConverterParameter=1}"/>
                                        <DiscreteDoubleKeyFrame KeyTime="0:0:1.1" Value="{Binding Width, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource MultiplyConverter}, ConverterParameter=2}" />
                                    </DoubleAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackContentPresenter" Storyboard.TargetProperty="Visibility"
                                                               Duration="0:0:1" FillBehavior="Stop">
                                        <ObjectAnimationUsingKeyFrames.KeyFrames>
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames.KeyFrames>
                                    </ObjectAnimationUsingKeyFrames>
                                    <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="(RenderTransform).X"
                                                               Duration="0:0:1">
                                        <DiscreteDoubleKeyFrame KeyTime="0" Value="{Binding Width, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource MultiplyConverter}, ConverterParameter=-1}"/>
                                        <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0" />
                                    </DoubleAnimationUsingKeyFrames>
                                </Storyboard>
                            </ResourceDictionary>
                        </Grid.Resources>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="contentGrid"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0"
                                                         To="{ThemeResource ListViewItemDisabledThemeOpacity}" />
                                        </Storyboard>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid x:Name="contentGrid" Background="{TemplateBinding Background}" >
                            <ContentPresenter x:Name="BackContentPresenter" Margin="{TemplateBinding Padding}" 
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                              Visibility="Collapsed">
                                <ContentPresenter.RenderTransform>
                                    <TranslateTransform/>
                                </ContentPresenter.RenderTransform>
                            </ContentPresenter>
                            <ContentPresenter x:Name="ContentPresenter" Margin="{TemplateBinding Padding}" 
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                                <ContentPresenter.RenderTransform>
                                    <TranslateTransform/>
                                </ContentPresenter.RenderTransform>
                            </ContentPresenter>
                            <ContentControl IsTabStop="False" Margin="{TemplateBinding Padding}" 
                                            Style="{StaticResource HeaderStyle}"
                                                ContentTemplate="{TemplateBinding HeaderTemplate}"
                                                Content="{TemplateBinding Header}"
                                                Padding="{TemplateBinding HeaderPadding}" 
                                                FontFamily="{TemplateBinding HeaderFontFamily}" 
                                                FontSize="{TemplateBinding HeaderFontSize}" 
                                                Background="{Binding HeaderBackground, RelativeSource={RelativeSource TemplatedParent}}"
                                                Foreground="{TemplateBinding HeaderForeground}" 
                                                HorizontalAlignment="{TemplateBinding HorizontalHeaderAlignment}" 
                                                VerticalAlignment="{TemplateBinding VerticalHeaderAlignment}"/>
                            <!-- these properties failed to assign, maybe this is prohibited in WinRT due to performance reasons
                                                FontStretch="{TemplateBinding HeaderFontStretch}" 
                                                FontStyle="{TemplateBinding HeaderFontStyle}" 
                                                FontWeight="{TemplateBinding HeaderFontWeight}" 
                              -->
                            <Border  
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"/>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="c1tile:C1FlipTile" BasedOn="{StaticResource C1TileBaseStyle}">
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="HorizontalHeaderAlignment" Value="Stretch" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="c1tile:C1FlipTile">
                    <Grid x:Name="LayoutRoot" >
                        <Grid.Resources>
                            <ResourceDictionary>
                                <Storyboard x:Key="ContentChangeAnimationFlip" FillBehavior="Stop">
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backGrid" Storyboard.TargetProperty="Visibility"
                                                               BeginTime="0:0:0.0" Duration="0:0:0.4" FillBehavior="Stop">
                                        <ObjectAnimationUsingKeyFrames.KeyFrames>
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames.KeyFrames>
                                    </ObjectAnimationUsingKeyFrames>
                                    <DoubleAnimation Storyboard.TargetProperty="RotationX" Storyboard.TargetName="BackProjection"
                                                             Duration="0:0:0.4" BeginTime="0:0:0.0" From="0" To="90"/>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="frontGrid" Storyboard.TargetProperty="Visibility"
                                                               BeginTime="0:0:0.0" Duration="0:0:0.42" FillBehavior="Stop">
                                        <ObjectAnimationUsingKeyFrames.KeyFrames>
                                            <DiscreteObjectKeyFrame KeyTime="0">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames.KeyFrames>
                                    </ObjectAnimationUsingKeyFrames>
                                    <DoubleAnimation Storyboard.TargetProperty="RotationX" Storyboard.TargetName="FrontProjection"
                                                             Duration="0:0:0.4" BeginTime="0:0:0.4" From="-90" To="0"/>
                                </Storyboard>
                            </ResourceDictionary>
                        </Grid.Resources>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="contentGrid"
                                                         Storyboard.TargetProperty="Opacity"
                                                         Duration="0"
                                                         To="{ThemeResource ListViewItemDisabledThemeOpacity}" />
                                        </Storyboard>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid x:Name="contentGrid">
                            <Grid x:Name="backGrid" Background="{TemplateBinding Background}" Visibility="Collapsed" 
                                  BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                                <Grid.Projection>
                                    <PlaneProjection  CenterOfRotationY="0.5" x:Name="BackProjection"/>
                                </Grid.Projection>
                                <ContentPresenter x:Name="BackContentPresenter" 
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                <ContentControl IsTabStop="False" Margin="{TemplateBinding Padding}" 
                                                Style="{StaticResource HeaderStyle}"
                                                ContentTemplate="{TemplateBinding HeaderTemplate}"
                                                Content="{TemplateBinding Header}"
                                                Padding="{TemplateBinding HeaderPadding}" 
                                                FontFamily="{TemplateBinding HeaderFontFamily}" 
                                                FontSize="{TemplateBinding HeaderFontSize}" 
                                                Foreground="{TemplateBinding HeaderForeground}" 
                                                Background="{TemplateBinding HeaderBackground}"
                                                HorizontalContentAlignment="{TemplateBinding HorizontalHeaderAlignment}" 
                                                VerticalAlignment="{TemplateBinding VerticalHeaderAlignment}"/>
                            </Grid>
                            <Grid x:Name="frontGrid" Background="{TemplateBinding Background}" 
                                  BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                                <Grid.Projection>
                                    <PlaneProjection  CenterOfRotationY="0.5" x:Name="FrontProjection"/>
                                </Grid.Projection>
                                <ContentPresenter x:Name="ContentPresenter" 
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                <ContentControl IsTabStop="False" Margin="{TemplateBinding Padding}" 
                                                Style="{StaticResource HeaderStyle}"
                                                ContentTemplate="{TemplateBinding HeaderTemplate}"
                                                Content="{TemplateBinding Header}"
                                                Padding="{TemplateBinding HeaderPadding}" 
                                                FontFamily="{TemplateBinding HeaderFontFamily}" 
                                                FontSize="{TemplateBinding HeaderFontSize}" 
                                                Foreground="{TemplateBinding HeaderForeground}" 
                                                Background="{TemplateBinding HeaderBackground}"
                                                HorizontalContentAlignment="{TemplateBinding HorizontalHeaderAlignment}" 
                                                VerticalAlignment="{TemplateBinding VerticalHeaderAlignment}"/>
                            </Grid>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
