<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:c1tv="using:C1.Xaml.TileView"
	xmlns:c1="using:C1.Xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"  >
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="ms-appx:///C1.UWP/themes/Common.xaml"/>
        <ResourceDictionary Source="ms-appx:///C1.UWP/themes/C1ScrollBar.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <!--******************* C1TileView *******************-->

    <!-- Brush @ TileView -->
    <SolidColorBrush x:Key="TileViewBackgroundBrush" Color="#26FFFFFF"/>
    <SolidColorBrush x:Key="TileViewHeaderBackground" Color="#3F000000"/>
    <SolidColorBrush x:Key="TileViewItemBackground" Color="#CCFFFFFF"/>
    <SolidColorBrush x:Key="TileViewBorderBrush" Color="#FFEEEEEE"/>
    <Thickness x:Key="TileViewThickness">0</Thickness>
    <SolidColorBrush x:Key="TileViewMouseOverBrush" Color="#FF404040"/>
    <SolidColorBrush x:Key="TileViewSelectedBackground" Color="#FFCCCCCC"/>

    <!-- CornerRadius @ TileViewItem -->
    <CornerRadius x:Key="TileViewItemCornerRadius">0</CornerRadius>
    <!-- CornerRadius @ TileViewItem Header -->
    <CornerRadius x:Key="TileViewItemHeaderCornerRadius">0</CornerRadius>

    <!-- Button @ TileViewItem -->
    <Style x:Key="TileViewItemStateButton" TargetType="Button">
        <Setter Property="Height" Value="42"/>
        <Setter Property="Width" Value="42"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MouseOverElement" Storyboard.TargetProperty="(UIElement.Visibility)" Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PressedElement" Storyboard.TargetProperty="(UIElement.Visibility)" Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="DisabledVisualElement"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused">
                                    <Storyboard>
                                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisualElement"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unfocused"/>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border x:Name="Background" Background="Transparent"/>
                        <Border x:Name="MouseOverElement" 
							Background="{TemplateBinding c1:ClearStyleExtensions.MouseOverBrush}" 
							Visibility="Collapsed"/>
                        <Border x:Name="PressedElement" 
							Background="{TemplateBinding c1:ClearStyleExtensions.PressedBrush}" 
							Visibility="Collapsed"/>
                        <ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        <Rectangle x:Name="DisabledVisualElement" Fill="{StaticResource DisabledBrush}" IsHitTestVisible="false" Opacity="0"/>
                        <Rectangle x:Name="FocusVisualElement" IsHitTestVisible="false" Stroke="{TemplateBinding c1:ClearStyleExtensions.FocusBrush}" StrokeThickness="1" Opacity="0"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!-- C1TileView -->
    <Style TargetType="c1tv:C1TileView">
        <Setter Property="Background" Value="{StaticResource TileViewBackgroundBrush}"/>
        <Setter Property="MouseOverBrush" Value="{ThemeResource ButtonPointerOverBackgroundThemeBrush}"/>
        <Setter Property="PressedBrush" Value="{ThemeResource ButtonPressedBackgroundThemeBrush}"/>
        <Setter Property="BorderBrush" Value="{ThemeResource ButtonBorderThemeBrush}"/>
        <Setter Property="HeaderBackground" Value="{StaticResource TileViewHeaderBackground}"/>
        <Setter Property="FocusBrush" Value="{ThemeResource SystemColorButtonFaceColor}"/>
        <Setter Property="BorderThickness" Value="{StaticResource TileViewThickness}"/>
        <Setter Property="ItemBackground" Value="{StaticResource TileViewItemBackground}"/>
        <Setter Property="ItemForeground" Value="{ThemeResource ComboBoxForegroundThemeBrush}" />
        <Setter Property="HeaderForeground" Value="{ThemeResource ButtonForegroundThemeBrush}" />
        <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}"/>
        <Setter Property="ScrollBarStyle" Value="{StaticResource ScrollBarClearStyle}" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Visible" />
        <Setter Property="Padding" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="c1tv:C1TileView">
                    <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition x:Name="MaxCol"></ColumnDefinition>
                                <ColumnDefinition x:Name="MinCol"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition x:Name="MaxRow"></RowDefinition>
                                <RowDefinition x:Name="MinRow"></RowDefinition>
                            </Grid.RowDefinitions>
                            <Border x:Name="MaximizedItemBorder">
                            </Border>
                            <ScrollViewer x:Name="ScrollViewer" HorizontalScrollMode="Auto" HorizontalScrollBarVisibility="Auto" 
                                      IsHorizontalRailEnabled="True" IsVerticalRailEnabled="True"
                                      Padding="{TemplateBinding Padding}" TabNavigation="{TemplateBinding TabNavigation}" 
                                      VerticalScrollBarVisibility="Auto" VerticalScrollMode="Auto" ZoomMode="Disabled"
                                      IsVerticalScrollChainingEnabled="False" IsZoomChainingEnabled="False"
                                      >
                                <ItemsPresenter />
                            </ScrollViewer>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <!--<ItemsPanelTemplate>-->
                <DataTemplate>
                    <c1tv:C1TileViewPanel />
                </DataTemplate>
                <!--</ItemsPanelTemplate>-->
            </Setter.Value>
        </Setter>
    </Style>

    <!-- C1TileViewItem -->
    <Style TargetType="c1tv:C1TileViewItem">
        <Setter Property="HeaderPadding" Value="5"/>
        <Setter Property="Padding" Value="5"/>
        <Setter Property="Margin" Value="1"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="HeaderFontSize" Value="16"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="c1tv:C1TileViewItem">
                    <Border Margin="{TemplateBinding Margin}" >
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="TiledStates">
                                <VisualState x:Name="Tiled"/>
                                <VisualState x:Name="Maximized" >
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Minimize" Storyboard.TargetProperty="(UIElement.Visibility)" Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Maximize" Storyboard.TargetProperty="(UIElement.Visibility)" Duration="0">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Minimized" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <Border x:Name="Header"
								Background="{TemplateBinding HeaderBackground}"
								CornerRadius="{StaticResource TileViewItemHeaderCornerRadius}">
                                <Grid MinHeight="42">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <!--
                                    FontStretch="{TemplateBinding HeaderFontStretch}"
										FontStyle="{TemplateBinding c1:C1HeaderedContentControl.HeaderFontStyle}"
										FontWeight="{TemplateBinding HeaderFontWeight}"
                                    -->
                                    <ContentControl
										IsTabStop="False"
										Content="{TemplateBinding Header}"
										Padding="{TemplateBinding HeaderPadding}"
										ContentTemplate="{TemplateBinding HeaderTemplate}"
										FontFamily="{TemplateBinding HeaderFontFamily}"
										FontSize="{TemplateBinding HeaderFontSize}"										
										Foreground="{TemplateBinding HeaderForeground}"
										HorizontalContentAlignment="{TemplateBinding HorizontalHeaderAlignment}"
										VerticalContentAlignment="Center"/>
                                    <Button x:Name="StateButton" Visibility="Collapsed"
										Grid.Column="1" Margin="5 2 2 2"
										VerticalAlignment="Center"
										c1:ClearStyleExtensions.MouseOverBrush="{TemplateBinding MouseOverBrush}"
										c1:ClearStyleExtensions.PressedBrush="{TemplateBinding PressedBrush}"
                                        c1:ClearStyleExtensions.FocusBrush="{TemplateBinding FocusBrush}"
										Style="{StaticResource TileViewItemStateButton}">
                                        <Grid>
                                            <Path
                                                x:Name="Minimize"
                                                Data="M12,17 L12,20 L12,26.5 L21,17.43 L24.57,21 L15.5,30 L25,30 L21,34 L8,34 L8,21 z M2,2 L2,40 L40,40 L40,2 z M0,0 L42,0 L42,42 L0,42 z"
                                                Height="42" Width="42"
                                                Stretch="Fill"
										        Fill="{TemplateBinding HeaderForeground}"
                                                Visibility="Collapsed"
                                              />
                                            <Path
                                                x:Name="Maximize"
                                                Data="M14,6 L24,6 L24,16 L21,19 L21,16.7 L21,11.76 L14,18.67 L11.33,16 L18.24,9 L11,9 z M2,2 L2,28 L28,28 L28,2 z M0,0 L30,0 L30,30 L0,30 z"
                                                Height="30" Width="30"
                                                Margin="6"
                                                Stretch="Fill" 
												Fill="{TemplateBinding HeaderForeground}" 
												/>
                                        </Grid>
                                    </Button>
                                </Grid>
                            </Border>

                            <Border  Grid.Row="1" 
							    Background="{TemplateBinding Background}"
					 		    BorderBrush="{TemplateBinding BorderBrush}"
							    BorderThickness="{TemplateBinding BorderThickness}"
							    CornerRadius="{StaticResource TileViewItemCornerRadius}">
                                <ContentPresenter x:Name="Presenter"
									    Margin="{TemplateBinding Padding}" 
									    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
									    VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content=""/>
                            </Border>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>