<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:ForzaUI" 
    xmlns:System="clr-namespace:System;assembly=mscorlib"
    mc:Ignorable="d"
    x:Class="ForzaUI.HUDPinnedChallengeControl"
    x:Name="UserControl"
    HorizontalAlignment="Left"
    VerticalAlignment="Bottom"
    Margin="0,0,0,349">

    <UserControl.Resources>
        <ResourceDictionary>
            <System:Double x:Key="A_Double_SlideIn">-50</System:Double>
            <System:Double x:Key="A_Double_SlideOut">-50</System:Double>

            <System:TimeSpan x:Key="A_Duration_SlideIn">0:0:0.5</System:TimeSpan>
            <System:TimeSpan x:Key="A_Duration_CompleteSlideOut_Delay">-0:0:0.3</System:TimeSpan>
            <System:TimeSpan x:Key="A_Duration_CompleteSlideOut">0:0:0.3</System:TimeSpan>
            <System:TimeSpan x:Key="A_Duration_FadeIn">0:0:0.25</System:TimeSpan>
            <System:TimeSpan x:Key="A_Duration_FadeOut">0:0:0.3</System:TimeSpan>
            <System:TimeSpan x:Key="A_Duration_ShowComplete">0:0:3.6</System:TimeSpan>

            <KeyTime x:Key="A_KeyTime_SlideInStart">0:0:0.0</KeyTime>
            <local:OffsetKeyTime x:Key="A_KeyTime_SlideInEnd"
                KeyTime="{StaticResource A_KeyTime_SlideInStart}"
                Offset="{StaticResource A_Duration_SlideIn}"/>

            <KeyTime x:Key="A_KeyTime_FadeInStart">0:0:0.0</KeyTime>
            <local:OffsetKeyTime x:Key="A_KeyTime_FadeInEnd"
                KeyTime="{StaticResource A_KeyTime_FadeInStart}"
                Offset="{StaticResource A_Duration_FadeIn}"/>

            <KeyTime x:Key="A_KeyTime_FadeOutStart">0:0:0.0</KeyTime>
            <local:OffsetKeyTime x:Key="A_KeyTime_FadeOutEnd"
                KeyTime="{StaticResource A_KeyTime_FadeOutStart}"
                Offset="{StaticResource A_Duration_FadeOut}"/>

            <local:OffsetKeyTime x:Key="A_KeyTime_CompleteFadeOutStart"
                KeyTime="{StaticResource A_KeyTime_FadeOutStart}"
                Offset="{StaticResource A_Duration_ShowComplete}"/>
            <local:OffsetKeyTime x:Key="A_KeyTime_CompleteFadeOutEnd"
                KeyTime="{StaticResource A_KeyTime_CompleteFadeOutStart}"
                Offset="{StaticResource A_Duration_FadeOut}"/>

            <local:OffsetKeyTime x:Key="A_KeyTime_CompleteSlideOutStart"
                KeyTime="{StaticResource A_KeyTime_CompleteFadeOutEnd}"
                Offset="{StaticResource A_Duration_CompleteSlideOut_Delay}"/>
            <local:OffsetKeyTime x:Key="A_KeyTime_CompleteSlideOutEnd"
                KeyTime="{StaticResource A_KeyTime_CompleteSlideOutStart}"
                Offset="{StaticResource A_Duration_CompleteSlideOut}"/>

            <System:Double x:Key="A_Double_HudChallenge_RowMaxWidth">340</System:Double>
            <System:Double x:Key="A_Double_HudChallenge_RowMinWidth">290</System:Double>

            <Color x:Key="A_Color_HudChallengeObjective_Checkbox">#80FFFFFF</Color>
            <Color x:Key="A_Color_HudChallengeObjective_Checkbox_Complete">#FFFFFFFF</Color>

            <Color x:Key="A_Color_HudChallengeObjective_Progress">#FFFFFFFF</Color>
            <Color x:Key="A_Color_HudChallengeObjective_Progress_Complete">#FF17FF90</Color>

            <Color x:Key="A_Color_HudChallengeObjective_Description">#FFFFFFFF</Color>
            <Color x:Key="A_Color_HudChallengeObjective_Description_Complete">#80FFFFFF</Color>

            <Style x:Key="A_Style_FZRun_Markup_HudChallenge_HIGHLIGHT"
                   TargetType="local:FZRun">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsComplete, FallbackValue={StaticResource A_Boolean_False}}" Value="{StaticResource A_Boolean_False}">
                        <Setter Property="Color"
                            Value="{StaticResource A_Color_HUD_AlternateText}"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_FZMaterial_HudChallengeItem"
                TargetType="{x:Type local:FZMaterial}"
                BasedOn="{StaticResource A_Style_FZMaterial_GlassHudItem}">
                <!--<Setter Property="Color" Value="{StaticResource A_Color_GlassPanel_NonInteractive}"/>-->
                <Setter Property="Height" Value="Auto" />
                <Setter Property="MinHeight" Value="{StaticResource A_Double_HUDMiniLeaderboard_RowHeight}" />
                <Setter Property="Margin" Value="0,3,0,0" />
            </Style>

            <Style x:Key="A_Style_FZMaterial_HudChallengeTitleItem"
                TargetType="{x:Type local:FZMaterial}"
                BasedOn="{StaticResource A_Style_FZMaterial_HudChallengeItem}">
                <Setter Property="Margin" Value="0,0,0,0"/>
                <Setter Property="Color" Value="{Binding BrickChallengeType, Converter={StaticResource A_Converter_BrickChallengeTypeToColor}}" />
                <Setter Property="Preset" Value="{StaticResource A_FZMaterialPresetRoundtangle_HudItem}" />
            </Style>

            <Style x:Key="A_Style_FZTextBlock_HudChallengeText"
                TargetType="{x:Type local:FZTextBlock}"
                BasedOn="{StaticResource A_Style_FZTextBlock_HudMedium}">
                <Setter Property="VerticalAlignment" Value="Center" />
                <Setter Property="Margin" Value="12,10" />
                <Setter Property="TextAlignment" Value="Left" />
                <Setter Property="TextWrapping" Value="Wrap" />
                <Setter Property="Stretch" Value="None" />
                <Setter Property="local:TextBlockInlineMarkup.ResourceBaseName" Value="A_Style_FZRun_Markup_HudChallenge_"/>
            </Style>

            <Style x:Key="A_Style_FZTextBlock_HudChallengeObjectiveDescription"
                TargetType="{x:Type local:FZTextBlock}"
                BasedOn="{StaticResource A_Style_FZTextBlock_HudChallengeText}">
                <Setter Property="Color" Value="{StaticResource A_Color_HudChallengeObjective_Description}" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsComplete, FallbackValue={StaticResource A_Boolean_False}}" Value="{StaticResource A_Boolean_True}">
                        <Setter Property="Color" Value="{StaticResource A_Color_HudChallengeObjective_Description_Complete}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_FZTextBlock_HudChallengeObjectiveProgress"
                TargetType="{x:Type local:FZTextBlock}"
                BasedOn="{StaticResource A_Style_FZTextBlock_HudChallengeText}">
                <Setter Property="Color" Value="{StaticResource A_Color_HudChallengeObjective_Progress}" />
                <Setter Property="VerticalAlignment" Value="Center" />
                <Setter Property="TextAlignment" Value="Right" />
                <Setter Property="TextWrapping" Value="NoWrap" />
                <Setter Property="Stretch" Value="Uniform" />
                <Setter Property="Margin" Value="0,10,12,10"/>
                <Setter Property="local:TextBlockInlineMarkup.Markup" Value="{Binding Progress}"/>
                <Setter Property="Visibility" Value="{Binding Progress, Converter={StaticResource A_StringVisConverter}}"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsComplete, FallbackValue={StaticResource A_Boolean_False}}" Value="{StaticResource A_Boolean_True}">
                        <Setter Property="Visibility" Value="{x:Static Visibility.Hidden}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <local:MappingConverter x:Key="A_Converter_TimerTypeToDescriptionFormatString"
                            Default="">
                <local:MappingConverterEntry Key="{x:Static local:BrickChallengeTimerType.Reset}" Value="{local:Loc Expansions.IDS_HUD_Pinned_DescriptionResetTimer}" />
                <local:MappingConverterEntry Key="{x:Static local:BrickChallengeTimerType.Sustain}" Value="{local:Loc Expansions.IDS_HUD_Pinned_DescriptionSustainTimer}" />
            </local:MappingConverter>

            <local:MultiConverter x:Key="A_Converter_TimerTypeToDescriptionVisibility">
                <local:MultiConverterEntry Converter="{StaticResource A_Converter_TimerTypeToDescriptionFormatString}" />
                <local:MultiConverterEntry Converter="{StaticResource A_StringVisConverter}" />
            </local:MultiConverter>

            <local:MappingConverter x:Key="A_Converter_BrickChallengeTypeToTextColor"
                            Default="{StaticResource A_Color_HUD_Text}">
                <local:MappingConverterEntry Key="{x:Static local:BrickChallengeType.Skill}" Value="{StaticResource A_Color_HUD_Text_Dark}" />
            </local:MappingConverter>

            <local:MappingConverter x:Key="A_Converter_BrickChallengeTypeToEffect"
                            Default="{StaticResource A_DropShadowEffect_DefaultHud}">
                <local:MappingConverterEntry Key="{x:Static local:BrickChallengeType.Skill}" Value="{x:Null}" />
            </local:MappingConverter>

            <Style x:Key="A_Style_FZTextBlock_HudChallengeTitle"
                TargetType="{x:Type local:FZTextBlock}"
                BasedOn="{StaticResource A_Style_FZTextBlock_HudChallengeText}">
                <Setter Property="TextWrapping" Value="NoWrap" />
                <Setter Property="Stretch" Value="Uniform" />
                <Setter Property="local:TextBlockInlineMarkup.Markup" Value="{Binding Title, Converter={StaticResource A_StringToUpper}}" />
                <Setter Property="Color" Value="{Binding BrickChallengeType, Converter={StaticResource A_Converter_BrickChallengeTypeToTextColor}}" />
                <Setter Property="Effect" Value="{Binding BrickChallengeType, Converter={StaticResource A_Converter_BrickChallengeTypeToEffect}}" />
            </Style>

            <Style x:Key="A_Style_FZMaterial_HudChallengeCheckmarkContainer"
                TargetType="{x:Type local:FZMaterial}">
                <Setter Property="Margin" Value="0,10,10,10"/>
                <Setter Property="Width" Value="16"/>
                <Setter Property="Height" Value="16"/>
                <Setter Property="VerticalAlignment" Value="Top"/>
                <Setter Property="HorizontalAlignment" Value="Right"/>
                <Setter Property="Color" Value="{StaticResource A_Color_HudChallengeObjective_Checkbox}"/>
                <Setter Property="Visibility" Value="{Binding Progress, Converter={StaticResource A_StringVisConverter_Inverse}}"/>
                <Setter Property="local:FZMaterial.Preset">
                    <Setter.Value>
                        <local:FZMaterialPresetRoundtangleStroke
                            CornerRadius="2"
                            Thickness="1.5"/>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsComplete, FallbackValue={StaticResource A_Boolean_False}}" Value="{StaticResource A_Boolean_True}">
                        <Setter Property="Visibility" Value="{x:Static Visibility.Visible}"/>
                        <Setter Property="Color" Value="{StaticResource A_Color_HudChallengeObjective_Checkbox_Complete}"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_FZMaterial_HudChallengeCheckmark"
                TargetType="{x:Type local:FZMaterial}">
                <Setter Property="Margin" Value="-9,-14,-13,-8"/>
                <Setter Property="Width" Value="22"/>
                <Setter Property="Height" Value="22"/>
                <Setter Property="VerticalAlignment" Value="Center"/>
                <Setter Property="HorizontalAlignment" Value="Center"/>
                <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Data_Bound/PDLC2/BrickChallenges/HUD/Tick.png"/>
                <Setter Property="Visibility" Value="{Binding IsComplete, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsComplete, FallbackValue={StaticResource A_Boolean_False}}" Value="{StaticResource A_Boolean_True}">
                        <Setter Property="Visibility" Value="{x:Static Visibility.Visible}"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <ControlTemplate x:Key="A_ControlTemplate_ItemsControl_HudChallengeObjectives"
                TargetType="ItemsControl">
                <StackPanel Orientation="Vertical" IsItemsHost="True" />
            </ControlTemplate>

            <DataTemplate x:Key="A_DataTemplate_HudChallengeObjective">
                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_HudChallengeItem}">
                    <DockPanel>
                        <Grid DockPanel.Dock="Right">
                            <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_HudChallengeCheckmarkContainer}">
                                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_HudChallengeCheckmark}"/>
                            </local:FZMaterial>
                            <Decorator MaxWidth="100"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Top"
                                Height="{StaticResource A_Double_HUDMiniLeaderboard_RowHeight}">
                                <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_HudChallengeObjectiveProgress}"/>
                            </Decorator>
                        </Grid>
                        <local:FZTextBlock DockPanel.Dock="Left"
                            local:TextBlockInlineMarkup.Markup="{Binding Description}"
                            Style="{StaticResource A_Style_FZTextBlock_HudChallengeObjectiveDescription}"/>
                    </DockPanel>
                </local:FZMaterial>
            </DataTemplate>

            <local:MultiConverter x:Key="A_Converter_HudChallenge_TimeRemaining">
                <local:MultiConverterEntry>
                    <local:MultiConverterEntry.Converter>
                        <local:LinearTransformConverter CeilOutput="True"/>
                    </local:MultiConverterEntry.Converter>
                </local:MultiConverterEntry>
                <local:MultiConverterEntry Converter="{StaticResource A_Converter_AbbreviatedTime}" />
            </local:MultiConverter>

            <local:UIStoryboard x:Key="A_Storyboard_PinnedChallenge_OnFailed">
                <local:UIStoryboard.TriggerAnimation>
                    <local:StartAudioTrigger local:TriggerAnimation.KeyTime="0:0:0.0" EventName="AudioUITrigger_Red_Challenge_Failed"/>
                </local:UIStoryboard.TriggerAnimation>
            </local:UIStoryboard>

            <local:UIStoryboard x:Key="A_Storyboard_PinnedChallenge_OnAchievedObjective">
                <local:UIStoryboard.TriggerAnimation>
                    <local:StartAudioTrigger local:TriggerAnimation.KeyTime="0:0:0.0" EventName="AudioUITrigger_Red_Challenge_Sub_Tick"/>
                </local:UIStoryboard.TriggerAnimation>
            </local:UIStoryboard>

            <System:Double x:Key="A_Double_SoftEdgeGlow_MaxOpacity">1.0</System:Double>
            <System:Double x:Key="A_Double_HardEdgeGlow_MaxOpacity">1.0</System:Double>

            <System:TimeSpan x:Key="A_Duration_SoftEdgeGlow_FadeIn">0:0:0.05</System:TimeSpan>
            <System:TimeSpan x:Key="A_Duration_SoftEdgeGlow_FadeOut">0:0:0.4</System:TimeSpan>
            <System:TimeSpan x:Key="A_Duration_SoftEdgeGlow_FadeOutDelay">0:0:0.05</System:TimeSpan>
            <KeyTime x:Key="A_KeyTime_SoftEdgeGlow_FadeInStart">0:0:0.0</KeyTime>
            <local:OffsetKeyTime x:Key="A_KeyTime_SoftEdgeGlow_FadeInEnd"
                KeyTime="{StaticResource A_KeyTime_SoftEdgeGlow_FadeInStart}"
                Offset="{StaticResource A_Duration_SoftEdgeGlow_FadeIn}"/>
            <local:OffsetKeyTime x:Key="A_KeyTime_SoftEdgeGlow_FadeOutStart"
                KeyTime="{StaticResource A_KeyTime_SoftEdgeGlow_FadeInEnd}"
                Offset="{StaticResource A_Duration_SoftEdgeGlow_FadeOutDelay}"/>
            <local:OffsetKeyTime x:Key="A_KeyTime_SoftEdgeGlow_FadeOutEnd"
                KeyTime="{StaticResource A_KeyTime_SoftEdgeGlow_FadeOutStart}"
                Offset="{StaticResource A_Duration_SoftEdgeGlow_FadeOut}"/>

            <System:TimeSpan x:Key="A_Duration_HardEdgeGlow_FadeIn">0:0:0.05</System:TimeSpan>
            <System:TimeSpan x:Key="A_Duration_HardEdgeGlow_FadeOut">0:0:0.4</System:TimeSpan>
            <System:TimeSpan x:Key="A_Duration_HardEdgeGlow_FadeOutDelay">0:0:0.05</System:TimeSpan>
            <KeyTime x:Key="A_KeyTime_HardEdgeGlow_FadeInStart">0:0:0.0</KeyTime>
            <local:OffsetKeyTime x:Key="A_KeyTime_HardEdgeGlow_FadeInEnd"
                KeyTime="{StaticResource A_KeyTime_HardEdgeGlow_FadeInStart}"
                Offset="{StaticResource A_Duration_HardEdgeGlow_FadeIn}"/>
            <local:OffsetKeyTime x:Key="A_KeyTime_HardEdgeGlow_FadeOutStart"
                KeyTime="{StaticResource A_KeyTime_HardEdgeGlow_FadeInEnd}"
                Offset="{StaticResource A_Duration_HardEdgeGlow_FadeOutDelay}"/>
            <local:OffsetKeyTime x:Key="A_KeyTime_HardEdgeGlow_FadeOutEnd"
                KeyTime="{StaticResource A_KeyTime_HardEdgeGlow_FadeOutStart}"
                Offset="{StaticResource A_Duration_HardEdgeGlow_FadeOut}"/>

            <local:OffsetKeyTime x:Key="A_KeyTime_ContentsSwitch"
                KeyTime="{StaticResource A_KeyTime_HardEdgeGlow_FadeInEnd}"
                Offset="0:0:0.0"/>

            <ControlTemplate x:Key="A_ControlTemplate_PinnedChallenge">
                <Grid x:Name="TemplateRoot"
                    RenderTransformOrigin="0.5,0.5">
                    <Grid.RenderTransform>
                        <TranslateTransform X="0"/>
                    </Grid.RenderTransform>
                    <DockPanel
                        MaxWidth="{StaticResource A_Double_HudChallenge_RowMaxWidth}"
                        MinWidth="{StaticResource A_Double_HudChallenge_RowMinWidth}">
                        <local:FZMaterial DockPanel.Dock="Bottom"
                            Style="{StaticResource A_Style_FZMaterial_HudChallengeItem}"
                            Visibility="{Binding TimerType, Converter={StaticResource A_Converter_TimerTypeToDescriptionVisibility}}">
                            <DockPanel>
                                <Decorator DockPanel.Dock="Right">
                                    <local:FZMaterial
                                        Style="{StaticResource A_Style_FZMaterial_HudChallengeCheckmarkContainer}">
                                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_HudChallengeCheckmark}"/>
                                    </local:FZMaterial>
                                </Decorator>
                                <local:FZTextBlock DockPanel.Dock="Left"
                                    local:MultiStringFormatter.Param0="{Binding TimeLeftSeconds, Converter={StaticResource A_Converter_HudChallenge_TimeRemaining}}"
                                    local:MultiStringFormatter.Format="{Binding TimerType, Converter={StaticResource A_Converter_TimerTypeToDescriptionFormatString}}"
                                    local:TextBlockInlineMarkup.Markup="{Binding (local:MultiStringFormatter.Output), RelativeSource={RelativeSource Self}}"
                                    Style="{StaticResource A_Style_FZTextBlock_HudChallengeObjectiveDescription}"/>
                            </DockPanel>
                        </local:FZMaterial>

                        <ItemsControl DockPanel.Dock="Bottom"
                            ItemsSource="{Binding Objectives}"
                            ItemTemplate="{StaticResource A_DataTemplate_HudChallengeObjective}"
                            Template="{StaticResource A_ControlTemplate_ItemsControl_HudChallengeObjectives}"/>

                        <Grid DockPanel.Dock="Top" Height="{StaticResource A_Double_HUDMiniLeaderboard_RowHeight}">
                            <local:FZMaterial x:Name="TitleChallenge"
                                Style="{StaticResource A_Style_FZMaterial_HudChallengeTitleItem}">
                                <Decorator RenderTransformOrigin="0.5,0.5"
                                    RenderTransform="{StaticResource A_Transform_Italic}">
                                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_HudChallengeTitle}"/>
                                </Decorator>
                            </local:FZMaterial>
                            <local:FZMaterial x:Name="TitleComplete"
                                Style="{StaticResource A_Style_FZMaterial_HudChallengeTitleItem}"
                                Color="#FFFFFFFF"
                                Preset="{StaticResource A_FZMaterialPresetRoundtangle_CompleteProgress_InnerAll}"
                                Visibility="{x:Static Visibility.Collapsed}">
                                <Decorator RenderTransformOrigin="0.5,0.5"
                                    RenderTransform="{StaticResource A_Transform_Italic}">
                                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_HudChallengeTitle}"
                                        Color="{StaticResource A_Color_HUD_Text_Dark}"
                                        local:TextBlockInlineMarkup.Markup="{local:Loc Expansions.IDS_HUD_Pinned_Complete}"
                                        Effect="{x:Null}"/>
                                </Decorator>
                            </local:FZMaterial>
                            <local:FZMaterial x:Name="TitleSoftEdgeGlow"
                                Style="{StaticResource A_Style_FZMaterial_HudChallengeTitleItem}"
                                Color="#FFFFFFFF"
                                Opacity="0.0"
                                Margin="-6">
                                <local:FZMaterial.Preset>
                                    <local:FZMaterialPresetRoundtangle BasedOn="{StaticResource A_FZMaterialPresetRoundtangle_HudItem}"
                                        Softness="12"
                                        CornerRadius="9"
                                        AlphaMode="Additive"/>
                                </local:FZMaterial.Preset>
                            </local:FZMaterial>
                            <local:FZMaterial x:Name="TitleHardEdgeGlow"
                                Style="{StaticResource A_Style_FZMaterial_HudChallengeTitleItem}"
                                Color="#FFFFFFFF"
                                Opacity="0.0">
                               <local:FZMaterial.Preset>
                                    <local:FZMaterialPresetRoundtangle BasedOn="{StaticResource A_FZMaterialPresetRoundtangle_HudItem}"
                                        AlphaMode="Additive"/>
                                </local:FZMaterial.Preset>
                            </local:FZMaterial>
                        </Grid>
                    </DockPanel>
                </Grid>
                <ControlTemplate.Triggers>
                    <DataTrigger Binding="{Binding IsComplete, FallbackValue={StaticResource A_Boolean_False}}" Value="{StaticResource A_Boolean_True}">
                        <DataTrigger.EnterActions>
                            <local:BeginUIStoryboard x:Name="BeginStoryboard_Complete">
                                <local:UIStoryboard FillBehavior="Stop">
                                    <local:UIStoryboard.TriggerAnimation>
                                        <local:RaiseFzEvent local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_CompleteFadeOutEnd}" EventName="CompleteComplete"/>
                                    </local:UIStoryboard.TriggerAnimation>
                                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="TemplateRoot">
                                        <EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="1"/>
                                        <EasingDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_CompleteFadeOutStart}" Value="1"/>
                                        <EasingDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_CompleteFadeOutEnd}" Value="0"/>
                                    </DoubleAnimationUsingKeyFrames>

                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                        Storyboard.TargetName="TitleChallenge">
                                        <DiscreteObjectKeyFrame KeyTime="{StaticResource A_KeyTime_ContentsSwitch}" Value="{x:Static Visibility.Collapsed}"/>
                                    </ObjectAnimationUsingKeyFrames>

                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                        Storyboard.TargetName="TitleComplete">
                                        <DiscreteObjectKeyFrame KeyTime="{StaticResource A_KeyTime_ContentsSwitch}" Value="{x:Static Visibility.Visible}"/>
                                    </ObjectAnimationUsingKeyFrames>

                                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="TemplateRoot">
                                        <EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="1"/>
                                        <EasingDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_CompleteFadeOutStart}" Value="1"/>
                                        <EasingDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_CompleteFadeOutEnd}" Value="0"/>
                                    </DoubleAnimationUsingKeyFrames>

                                    <DoubleAnimationUsingKeyFrames
                                        Storyboard.TargetName="TitleHardEdgeGlow"
                                        Storyboard.TargetProperty="(UIElement.Opacity)">
                                        <DiscreteDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_HardEdgeGlow_FadeInStart}"
                                            Value="0.0"/>
                                        <EasingDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_HardEdgeGlow_FadeInEnd}"
                                            Value="{StaticResource A_Double_HardEdgeGlow_MaxOpacity}"
                                            EasingFunction="{local:LinearEasing}" />
                                        <DiscreteDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_HardEdgeGlow_FadeOutStart}"
                                            Value="{StaticResource A_Double_HardEdgeGlow_MaxOpacity}"/>
                                        <EasingDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_HardEdgeGlow_FadeOutEnd}"
                                            Value="0.0"
                                            EasingFunction="{local:LinearEasing}" />
                                    </DoubleAnimationUsingKeyFrames>

                                    <DoubleAnimationUsingKeyFrames
                                        Storyboard.TargetName="TitleSoftEdgeGlow"
                                        Storyboard.TargetProperty="(UIElement.Opacity)">
                                        <DiscreteDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_SoftEdgeGlow_FadeInStart}"
                                            Value="0.0"/>
                                        <EasingDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_SoftEdgeGlow_FadeInEnd}"
                                            Value="{StaticResource A_Double_SoftEdgeGlow_MaxOpacity}"
                                            EasingFunction="{local:LinearEasing}" />
                                        <DiscreteDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_SoftEdgeGlow_FadeOutStart}"
                                            Value="{StaticResource A_Double_SoftEdgeGlow_MaxOpacity}"/>
                                        <EasingDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_SoftEdgeGlow_FadeOutEnd}"
                                            Value="0.0"
                                            EasingFunction="{local:LinearEasing}" />
                                    </DoubleAnimationUsingKeyFrames>

                                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="TemplateRoot">
                                        <DiscreteDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_CompleteSlideOutStart}" Value="0"/>
                                        <EasingDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_CompleteSlideOutEnd}" Value="{StaticResource A_Double_SlideOut}" EasingFunction="{local:QuadraticEasing EasingMode=EaseIn}"/>
                                    </DoubleAnimationUsingKeyFrames>
                                </local:UIStoryboard>
                            </local:BeginUIStoryboard>
                        </DataTrigger.EnterActions>
                        <DataTrigger.ExitActions>
                            <StopStoryboard BeginStoryboardName="BeginStoryboard_Complete"/>
                        </DataTrigger.ExitActions>
                        <Setter TargetName="TemplateRoot" Property="Opacity" Value="0"/>
                    </DataTrigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>

            <Style x:Key="A_Style_Control_PinnedChallenge"
                TargetType="{x:Type Control}">
                <Setter Property="Template" Value="{StaticResource A_ControlTemplate_PinnedChallenge}"/>
                <Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
                <Setter Property="RenderTransform">
                    <Setter.Value>
                        <TranslateTransform X="0"/>
                    </Setter.Value>
                </Setter>
            </Style>

            <BackEase x:Key="A_SlideInEase" Amplitude="0.5"/>

        </ResourceDictionary>
    </UserControl.Resources>

    <Control x:Name="LayoutRoot"
        Style="{StaticResource A_Style_Control_PinnedChallenge}"
        DataContext="{Binding Challenge}"
        Opacity="0">
        <VisualStateManager.VisualStateGroups>
            <local:UIVisualStateGroup x:Name="VisualStateGroup">
                <VisualState x:Name="Shown">
                    <local:UIStoryboard>
                        <local:UIStoryboard.TriggerAnimation>
                            <local:RaiseFzEvent local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_FadeInEnd}" EventName="ShownComplete"/>
                        </local:UIStoryboard.TriggerAnimation>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="LayoutRoot">
                            <EasingDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_FadeInEnd}" Value="1"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)" Storyboard.TargetName="LayoutRoot">
                            <DiscreteDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_SlideInStart}" Value="{StaticResource A_Double_SlideIn}"/>
                            <EasingDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_SlideInEnd}" Value="0" EasingFunction="{StaticResource A_SlideInEase}"/>
                        </DoubleAnimationUsingKeyFrames>
                    </local:UIStoryboard>
                </VisualState>
                <VisualState x:Name="Hidden">
                    <local:UIStoryboard>
                        <local:UIStoryboard.TriggerAnimation>
                            <local:RaiseFzEvent local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_FadeOutEnd}" EventName="HiddenComplete"/>
                        </local:UIStoryboard.TriggerAnimation>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="LayoutRoot">
                            <EasingDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_FadeOutEnd}" Value="0"/>
                        </DoubleAnimationUsingKeyFrames>
                    </local:UIStoryboard>
                </VisualState>
            </local:UIVisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Control>
    <local:EventFire.FzTriggers>
        <local:EventFireTrigger Event="HasJustFailed" Storyboard="{StaticResource A_Storyboard_PinnedChallenge_OnFailed}"/>
        <local:EventFireTrigger Event="HasJustAchievedObjective" Storyboard="{StaticResource A_Storyboard_PinnedChallenge_OnAchievedObjective}"/>
    </local:EventFire.FzTriggers>
</UserControl>