<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:c1="using:C1.Xaml">
	<ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="ms-appx:///C1.UWP/themes/Common.xaml"/>
	</ResourceDictionary.MergedDictionaries>

	<!--******************** C1ValidationDecorator *********************-->

	<Style x:Key="ValidationToolTipStyle" TargetType="ToolTip">
        <Setter Property="Background" Value="{StaticResource ValidationBaseColorBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource ValidationForegroundBrush}"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="ToolTip">
                    <Grid x:Name="Root" Margin="5 0" Opacity="0" RenderTransformOrigin="0,0">
                        <Grid.RenderTransform>
                            <TranslateTransform x:Name="xform" X="-25"/>
                        </Grid.RenderTransform>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="OpenStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0"/>
                                    <VisualTransition GeneratedDuration="0:0:0.2" To="Open">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="xform" Storyboard.TargetProperty="X">
                                                <SplineDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity">
                                                <SplineDoubleKeyFrame KeyTime="0:0:0.2" Value="1"/>
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualTransition>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Closed">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="0"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Open">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="xform" Storyboard.TargetProperty="X">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="0"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity">
                                            <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border Background="{TemplateBinding Background}" CornerRadius="2">
                            <ContentPresenter x:Name="Content" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
                        </Border>
                    </Grid>
                </ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<!-- C1ValidationDecorator Style-->
	<Style TargetType="c1:C1ValidationDecorator">
        <Setter Property="Background" Value="{StaticResource ValidationBaseColorBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource ValidationForegroundBrush}"/>
		<Setter Property="CornerRadius" Value="1"/>
		<Setter Property="BorderThickness" Value="1"/>
		<Setter Property="IsTabStop" Value="False" />
		<Setter Property="IsHitTestVisible" Value="False"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="c1:C1ValidationDecorator">
					<Border x:Name="ValidationErrorElement" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}" BorderBrush="{TemplateBinding Background}" Visibility="Collapsed">
						<VisualStateManager.VisualStateGroups>
							<VisualStateGroup x:Name="ValidationStates">
								<VisualState x:Name="Valid"/>
								<VisualState x:Name="InvalidUnfocused">
									<Storyboard>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ValidationErrorElement" Storyboard.TargetProperty="Visibility">
											<DiscreteObjectKeyFrame KeyTime="0">
												<DiscreteObjectKeyFrame.Value>
													<Visibility>Visible</Visibility>
												</DiscreteObjectKeyFrame.Value>
											</DiscreteObjectKeyFrame>
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="InvalidFocused">
									<Storyboard>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ValidationErrorElement" Storyboard.TargetProperty="Visibility">
											<DiscreteObjectKeyFrame KeyTime="0">
												<DiscreteObjectKeyFrame.Value>
													<Visibility>Visible</Visibility>
												</DiscreteObjectKeyFrame.Value>
											</DiscreteObjectKeyFrame>
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip" Storyboard.TargetProperty="IsOpen">
											<DiscreteObjectKeyFrame KeyTime="0" Value="True"/>
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
							</VisualStateGroup>
						</VisualStateManager.VisualStateGroups>
						<ToolTipService.ToolTip>
                            <ToolTip x:Name="validationTooltip" 
									 Background="{TemplateBinding Background}"
									 Foreground="{TemplateBinding Foreground}"
									 Placement="Right"
									 PlacementTarget="{TemplateBinding Target}"
									 Style="{StaticResource ValidationToolTipStyle}"
									>
                                <ToolTip.ContentTemplate>
									<DataTemplate>
										<TextBlock Margin="8 4" MaxWidth="250" VerticalAlignment="Center" Text="{Binding Path=[0].ErrorContent}" TextWrapping="Wrap"/>
									</DataTemplate>
								</ToolTip.ContentTemplate>
								<ToolTip.Triggers>
									<EventTrigger RoutedEvent="Canvas.Loaded">
										<EventTrigger.Actions>
											<BeginStoryboard>
												<Storyboard>
													<ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip" Storyboard.TargetProperty="IsHitTestVisible">
														<DiscreteObjectKeyFrame KeyTime="0" Value="True"/>
													</ObjectAnimationUsingKeyFrames>
												</Storyboard>
											</BeginStoryboard>
										</EventTrigger.Actions>
									</EventTrigger>
								</ToolTip.Triggers>
							</ToolTip>
						</ToolTipService.ToolTip>
						<Path Data="M 1,0 L6,0 A 2,2 90 0 1 8,2 L8,7 z"
								Fill="{TemplateBinding Background}" 
								Margin="0 -1 -1 0" 
								HorizontalAlignment="Right" 
								VerticalAlignment="Top"/>
					</Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>
