<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:ghfvs="https://github.com/github/VisualStudio"
    xmlns:local="clr-namespace:GitHub.UI"
    xmlns:rxui="clr-namespace:ReactiveUI;assembly=ReactiveUI">
    <Style TargetType="{x:Type local:UserErrorMessages}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:UserErrorMessages}">
                    <Grid x:Name="grid" Visibility="Hidden" Opacity="0" HorizontalAlignment="Center">
                        <Grid.LayoutTransform>
                            <ScaleTransform x:Name="ScaleTransform" ScaleX="1" ScaleY="0" />
                        </Grid.LayoutTransform>

                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
 
                        <Viewbox
                            Grid.Column="0"
                            VerticalAlignment="Center"
                            Margin="{TemplateBinding IconMargin}"
                            HorizontalAlignment="Right"
                            Width="16"
                            Height="16">
                            <ghfvs:OcticonPath x:Name="icon" Icon="{TemplateBinding Icon}" Height="16" Fill="{TemplateBinding Fill}" />
                        </Viewbox>

                        <TextBlock Grid.Column="1"
                                   Text="{Binding Path=ErrorMessage}"
                                   ToolTip="{Binding Path=ErrorCauseOrResolution}"
                                   HorizontalAlignment="Stretch"
                                   VerticalAlignment="Center"
                                   TextWrapping="Wrap"
                                   FontWeight="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:UserErrorMessages}},Path=ErrorMessageFontWeight}"
                                   Margin="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:UserErrorMessages}},Path=MessageMargin}"/>

                        <ItemsControl Grid.Column="2" 
                                      ItemsSource="{Binding RecoveryOptions}"
                                      VerticalAlignment="Center">
                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <StackPanel Orientation="Horizontal"/>
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Margin="4,0,0,0">
                                        <Hyperlink Command="{Binding}">
                                            <TextBlock Text="{Binding CommandName}"/>
                                        </Hyperlink>
                                    </TextBlock>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
                    </Grid>
                    
                    <ControlTemplate.Resources>

                        <Storyboard x:Key="Show" Storyboard.TargetName="grid">
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0.0" Value="{x:Static Visibility.Visible}"/>
                                </ObjectAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.LayoutTransform).(ScaleTransform.ScaleY)">
                                <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                                <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)">
                                <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
                                <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                        <Storyboard x:Key="Hide" Storyboard.TargetName="grid">
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)">
                                <DiscreteObjectKeyFrame KeyTime="0:0:0.0" Value="{x:Static Visibility.Hidden}"/>
                            </ObjectAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.LayoutTransform).(ScaleTransform.ScaleY)">
                                <SplineDoubleKeyFrame KeyTime="0:0:0.2" Value="1"/>
                                <SplineDoubleKeyFrame KeyTime="0:0:0.4" Value="0"/>
                            </DoubleAnimationUsingKeyFrames>
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)">
                                <SplineDoubleKeyFrame KeyTime="0" Value="1"/>
                                <SplineDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </ControlTemplate.Resources>

                    <ControlTemplate.Triggers>

                        <Trigger Property="IsShowingMessage" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard x:Name="Show_BeginStoryboard" Storyboard="{StaticResource Show}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <RemoveStoryboard BeginStoryboardName="Show_BeginStoryboard"/>
                            </Trigger.ExitActions>
                        </Trigger>

                        <Trigger Property="IsShowingMessage" Value="False">
                            <Trigger.EnterActions>
                                <BeginStoryboard x:Name="Hide_BeginStoryboard" Storyboard="{StaticResource Hide}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <RemoveStoryboard BeginStoryboardName="Hide_BeginStoryboard"/>
                            </Trigger.ExitActions>
                        </Trigger>
                        
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>