<UserControl
    DataContext="{Binding (HUDData.Data), RelativeSource={RelativeSource Self}}" 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:System="clr-namespace:System;assembly=mscorlib"
    mc:Ignorable="d"
    xmlns:local="clr-namespace:ForzaUI" 
    x:Class="ForzaUI.HUDChallengeControl"
    x:Name="UserControl"
    RenderTransformOrigin="0.5,0.5"
    Margin="0,0,0,0"
    HorizontalAlignment="Left"
    VerticalAlignment="Top">

    <UserControl.Resources>
        <ResourceDictionary>
            <System:Double x:Key="A_Double_HUDChallenge_RowHeight">32</System:Double>

            <Style x:Key="A_Style_FZTextBlock_HudMedium_BucketList" TargetType="{x:Type local:FZTextBlock}" BasedOn="{StaticResource A_Style_FZTextBlock_HUDBase}">
                <Setter Property="CapHeight" Value="17"/>
                <Setter Property="VerticalAlignment" Value="Center"/>
            </Style>

            <Style x:Key="A_Style_FrameworkElement_Challenge_DynamicTextContainer" TargetType="{x:Type local:FrameworkElement}">
                <Setter Property="RenderTransform" Value="{StaticResource A_SkewTransform_HUD_Italics}"/>
                <Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
            </Style>

            <Style x:Key="A_Style_FZTextBlock_Challenge_DynamicText" TargetType="{x:Type local:FZTextBlock}" BasedOn="{StaticResource A_Style_FZTextBlock_HudMedium_BucketList}">
                <Setter Property="FontFamily" Value="Horizon_A_tf"/>
            </Style>

            <Style x:Key="A_Style_FZTextBlock_Challenge_DynamicText_Highlighted" TargetType="{x:Type local:FZTextBlock}" BasedOn="{StaticResource A_Style_FZTextBlock_Challenge_DynamicText}">
                <Setter Property="Color" Value="{StaticResource A_Color_HUD_HighlightText}"/>
            </Style>

            <Style x:Key="A_Style_FZMaterial_Challenge_PillBackground" TargetType="{x:Type FZMaterial}" BasedOn="{StaticResource A_Style_FZMaterial_DarkGlassHudItem}">
                <Setter Property="Preset" Value="{FZMaterialPresetGlass BlurAmount=High}"/>
            </Style>

            <Style x:Key="A_Style_FZTextBlock_Challenge_ProgressText" TargetType="{x:Type local:FZTextBlock}" BasedOn="{StaticResource A_Style_FZTextBlock_Challenge_DynamicText}">
                <Setter Property="CapHeight" Value="56"/>
            </Style>

            <Style x:Key="A_Style_FZTextBlock_Challenge_ProgressTitleText" TargetType="{x:Type local:FZTextBlock}" BasedOn="{StaticResource A_Style_FZTextBlock_HudMedium_BucketList}">
                <Setter Property="CapHeight" Value="26"/>
                <Setter Property="VerticalAlignment" Value="Top"/>
            </Style>

            <Thickness x:Key="A_Thickness_BucketList_TextMargin">0,0,0,0</Thickness>

            <Thickness x:Key="A_Thickness_BucketList_ItemMargin_TimeRemaining">0,0,0,8</Thickness>
            <Thickness x:Key="A_Thickness_BucketList_ItemMargin">0,4,0,4</Thickness>

            <local:MappingConverter x:Key="A_MappingConverter_TimeRemaining_Visibility" Default="Visible">
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.Destination}" Value="{x:Static Visibility.Collapsed}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.SurfaceDrive}" Value="{x:Static Visibility.Collapsed}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.HardcoreSprint}" Value="{x:Static Visibility.Collapsed}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.DamageControl}" Value="{x:Static Visibility.Collapsed}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.MaintainMinSpeed}" Value="{x:Static Visibility.Collapsed}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.MaintainSpeed}" Value="{x:Static Visibility.Collapsed}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.DrivatarRace}" Value="{x:Static Visibility.Collapsed}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.PhotoChallenge}" Value="{x:Static Visibility.Collapsed}" />
            </local:MappingConverter>

            <local:MappingConverter x:Key="A_MappingConverter_Current_Visibility" Default="Collapsed">
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.Destination}" Value="{x:Static Visibility.Visible}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.SkillScore}" Value="{x:Static Visibility.Visible}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.SkillMastery}" Value="{x:Static Visibility.Visible}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.Smashable}" Value="{x:Static Visibility.Visible}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.SkillDrive}" Value="{x:Static Visibility.Visible}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.StuntDrive}" Value="{x:Static Visibility.Visible}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.SurfaceDrive}" Value="{x:Static Visibility.Visible}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.HardcoreSprint}" Value="{x:Static Visibility.Visible}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.MultiSpeedTrap}" Value="{x:Static Visibility.Visible}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.MultiSpeedZone}" Value="{x:Static Visibility.Visible}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.MultiDriftZone}" Value="{x:Static Visibility.Visible}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.MultiDangerSign}" Value="{x:Static Visibility.Visible}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.MultiSpeedTrapCount}" Value="{x:Static Visibility.Visible}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.MultiSpeedZoneCount}" Value="{x:Static Visibility.Visible}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.DamageControl}" Value="{x:Static Visibility.Visible}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.MaintainMinSpeed}" Value="{x:Static Visibility.Visible}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.MaintainSpeed}" Value="{x:Static Visibility.Visible}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.PhotoChallenge}" Value="{x:Static Visibility.Visible}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.DrivatarRace}" Value="{x:Static Visibility.Visible}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.Trailblazer}" Value="{x:Static Visibility.Visible}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.MultiDestination}" Value="{x:Static Visibility.Visible}" />

            </local:MappingConverter>

            <local:MappingConverter x:Key="A_MappingConverter_Current_Visibility_CreateFlow" Default="Collapsed">
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.SkillScore}" Value="{x:Static Visibility.Visible}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.SkillDrive}" Value="{x:Static Visibility.Visible}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.SkillMastery}" Value="{x:Static Visibility.Visible}" />
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.StuntDrive}" Value="{x:Static Visibility.Visible}" />
            </local:MappingConverter>

            <local:MappingConverter x:Key="A_MappingConverter_ChallengeLogo_Visibility" Default="Collapsed">
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.HorizonChase}" Value="{x:Static Visibility.Visible}" />
            </local:MappingConverter>

            <local:MappingConverter x:Key="A_MappingConverter_ChallengeLogo" Default="">
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.HorizonChase}" Value="/ForzaUI;component/Textures/Data_Bound/HUD/ChallengeType/Chase.png" />
            </local:MappingConverter>

            <local:Style x:Key="A_Style_ChallengeLogo" TargetType="FZMaterial">
                <Setter Property="ImageSource" Value="{Binding DataContext.ChallengeType, RelativeSource={RelativeSource AncestorType=UserControl}, Converter={StaticResource A_MappingConverter_ChallengeLogo}}"/>
                <Setter Property="Visibility" Value="{Binding DataContext.ChallengeType, RelativeSource={RelativeSource AncestorType=UserControl}, Converter={StaticResource A_MappingConverter_ChallengeLogo_Visibility}}"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding DataContext.IsStuntParty, RelativeSource={RelativeSource AncestorType=UserControl}}" Value="True">
                        <Setter Property="Visibility" Value="{x:Static Visibility.Visible}"/>
                        <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Data_Bound/HUD/ChallengeType/Stunt_Party_Logo.png"/>
                    </DataTrigger>
                </Style.Triggers>
            </local:Style>

            <local:MappingConverter x:Key="A_MappingConverter_TimeRemainingMargin" Default="10,0,10,0">
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.HorizonChase}" Value="120,0,10,0" />
            </local:MappingConverter>

            <local:MappingConverter x:Key="A_MappingConverter_Damage_Visibility" Default="Collapsed">
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.DamageControl}" Value="{x:Static Visibility.Visible}" />
            </local:MappingConverter>

            <local:MappingConverter x:Key="A_MappingConverter_Target_Remaining_Visibility" Default="Collapsed">
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.Trailblazer}" Value="{x:Static Visibility.Visible}" />
            </local:MappingConverter>

            <local:MappingConverter x:Key="A_Converter_HUDSceneToVisibility_Default" Default="Visible">
                <local:MappingConverterEntry Key="{x:Static local:SceneEntryEnum.BucketListChallengeCreationHud}" Value="{x:Static Visibility.Collapsed}" />
            </local:MappingConverter>

            <local:MappingConverter x:Key="A_Converter_HUDSceneToVisibility_CreateFlow" Default="Collapsed">
                <local:MappingConverterEntry Key="{x:Static local:SceneEntryEnum.BucketListChallengeCreationHud}" Value="{x:Static Visibility.Visible}" />
            </local:MappingConverter>

            <local:MappingConverter x:Key="A_Converter_TimeRemainingMargin" Default="{StaticResource A_Thickness_BucketList_ItemMargin_TimeRemaining}">
                <local:MappingConverterEntry Key="True" Value="0,-7,0,8"/>
            </local:MappingConverter>

            <Style x:Key="A_Style_FZTextBlock_TimeRemaningText" TargetType="{x:Type local:FZTextBlock}" BasedOn="{StaticResource A_Style_FZTextBlock_HudMedium_BucketList}">
                <Setter Property="Margin" Value="{Binding DataContext.ChallengeType, RelativeSource={RelativeSource AncestorType=UserControl}, Converter={StaticResource A_MappingConverter_TimeRemainingMargin}}"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding DataContext.IsStuntParty, RelativeSource={RelativeSource AncestorType=UserControl}}" Value="True">
                        <Setter Property="Margin" Value="120,0,10,0"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <ControlTemplate x:Key="A_ControlTemplate_Control_TimeRemaining">
                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Challenge_PillBackground}" 
                                  Margin="{Binding ShowMiniMissionItem, Converter={StaticResource A_Converter_TimeRemainingMargin}}"
                                  Height="{StaticResource A_Double_HUDChallenge_RowHeight}"
                                  Visibility="{Binding Label, Converter={StaticResource A_StringVisConverter}, FallbackValue=Collapsed}">
                    <Grid Margin="{StaticResource A_Thickness_BucketList_TextMargin}">
                        <local:FZMaterial Height="80"
                                          Width="130"
                                          VerticalAlignment="Center"
                                          HorizontalAlignment="Left"
                                          Margin="-10,0"
                                          Style="{StaticResource A_Style_ChallengeLogo}"/>
                        <local:FZTextBlock HorizontalAlignment="Left" Text="{Binding Label}" Style="{StaticResource A_Style_FZTextBlock_TimeRemaningText}" MaxWidth="170"/>
                        <Decorator Style="{StaticResource A_Style_FrameworkElement_Challenge_DynamicTextContainer}">
                            <local:FZTextBlock HorizontalAlignment="Right" Text="{Binding FormattedValue, Converter={StaticResource A_StringToUpper}}" Style="{StaticResource A_Style_FZTextBlock_Challenge_DynamicText}" MaxWidth="170" Margin="10,0,10,0"/>
                        </Decorator>
                    </Grid>
                </local:FZMaterial>
            </ControlTemplate>

            <Double x:Key="A_Double_HudChallenge_PillWidth">312</Double>
            <Double x:Key="A_Double_HudChallengeWithLogo_PillWidth">416</Double>

            <local:MappingConverter x:Key="A_MappingConverter_PillWidth" Default="{StaticResource A_Double_HudChallenge_PillWidth}">
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.HorizonChase}" Value="{StaticResource A_Double_HudChallengeWithLogo_PillWidth}" />
            </local:MappingConverter>

            <local:Style x:Key="A_Style_FrameworkElement_PillMinWidth" TargetType="{x:Type FrameworkElement}">
                <Setter Property="MinWidth" Value="{Binding ChallengeType, Converter={StaticResource A_MappingConverter_PillWidth}}"/>
                <local:Style.Triggers>
                    <DataTrigger Binding="{Binding IsStuntParty}" Value="True">
                        <Setter Property="MinWidth" Value="{StaticResource A_Double_HudChallengeWithLogo_PillWidth}"/>
                    </DataTrigger>
                </local:Style.Triggers>
            </local:Style>

            <local:Style x:Key="A_Style_FrameworkElement_PillWidth" TargetType="{x:Type FrameworkElement}">
                <Setter Property="Width" Value="{Binding ChallengeType, Converter={StaticResource A_MappingConverter_PillWidth}}"/>
                <local:Style.Triggers>
                    <DataTrigger Binding="{Binding IsStuntParty}" Value="True">
                        <Setter Property="Width" Value="{StaticResource A_Double_HudChallengeWithLogo_PillWidth}"/>
                    </DataTrigger>
                </local:Style.Triggers>
            </local:Style>

            <ControlTemplate x:Key="A_ControlTemplate_Control_Target">
                <local:FZMaterial x:Name="Container"
                                  Style="{StaticResource A_Style_FZMaterial_Challenge_PillBackground}" 
                                  Height="{StaticResource A_Double_HUDChallenge_RowHeight}">
                    <Viewbox StretchDirection="DownOnly">
                        <Grid Style="{StaticResource A_Style_FrameworkElement_PillMinWidth}">
                            <DockPanel Margin="{StaticResource A_Thickness_BucketList_TextMargin}">
                                <local:FZTextBlock DockPanel.Dock="Left" HorizontalAlignment="Left" Text="{Binding Target.Label}" Style="{StaticResource A_Style_FZTextBlock_HudMedium_BucketList}" Margin="10,0,10,0"/>
                                <local:FZTextBlock DockPanel.Dock="Right" HorizontalAlignment="Right" Text="{Loc BucketList.IDS_HUD_TargetRemaining}" Style="{StaticResource A_Style_FZTextBlock_HudMedium_BucketList}" Margin="0,0,10,0" Visibility="{Binding ChallengeType, Converter={StaticResource A_MappingConverter_Target_Remaining_Visibility}}"/>
                                <Decorator Style="{StaticResource A_Style_FrameworkElement_Challenge_DynamicTextContainer}">
                                    <local:FZTextBlock DockPanel.Dock="Right" x:Name="Value" HorizontalAlignment="Right" Text="{Binding Target.FormattedValue, Converter={StaticResource A_StringToUpper}}" Style="{StaticResource A_Style_FZTextBlock_Challenge_DynamicText}" Margin="0,0,10,0"/>
                                </Decorator>
                            </DockPanel>
                        </Grid>
                    </Viewbox>
                </local:FZMaterial>
            </ControlTemplate>
            <ControlTemplate x:Key="A_ControlTemplate_Control_Current">
                <local:FZMaterial x:Name="Container"
                                  Style="{StaticResource A_Style_FZMaterial_Challenge_PillBackground}"
                                  Height="{StaticResource A_Double_HUDChallenge_RowHeight}" 
                                  Margin="0,4,0,0">
                    <Grid Style="{StaticResource A_Style_FrameworkElement_PillMinWidth}">
                        <DockPanel Margin="{StaticResource A_Thickness_BucketList_TextMargin}">
                            <local:FZTextBlock DockPanel.Dock="Left" 
                                               HorizontalAlignment="Left"
                                               Text="{Binding Current.Label}"
                                               Style="{StaticResource A_Style_FZTextBlock_HudMedium_BucketList}"
                                               Margin="10,0,10,0"/>
                            <Decorator Style="{StaticResource A_Style_FrameworkElement_Challenge_DynamicTextContainer}">
                                <local:FZTextBlock DockPanel.Dock="Right"
                                               HorizontalAlignment="Right"
                                               Text="{Binding Current.FormattedValue, Converter={StaticResource A_StringToUpper}}"
                                               Style="{StaticResource A_Style_FZTextBlock_Challenge_DynamicText_Highlighted}"
                                               Margin="0,0,10,0"/>
                            </Decorator>
                        </DockPanel>
                    </Grid>
                </local:FZMaterial>
                <ControlTemplate.Triggers>
                    <DataTrigger Binding="{Binding ChallengeType}" Value="{x:Static local:HUDChallengeType.DamageControl}">
                        <Setter TargetName="Container" Property="Margin" Value="{StaticResource A_Thickness_BucketList_ItemMargin}"/>
                    </DataTrigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>

            <local:LinearTransformConverter x:Key="A_LinearTransformConverter_MaxBarWidth" Scale="156"/>
            <Color x:Key="A_Color_HUD_DamageBar_Background">#73000000</Color>
            <ControlTemplate x:Key="A_ControlTemplate_Control_Damage">
                <local:FZMaterial x:Name="Damage"
                              Style="{StaticResource A_Style_FZMaterial_Challenge_PillBackground}"
                              Height="{StaticResource A_Double_HUDChallenge_RowHeight}" >
                    <Grid>
                        <Grid Margin="{StaticResource A_Thickness_BucketList_TextMargin}">
                            <local:FZTextBlock HorizontalAlignment="Left" Text="{Binding Damage.Label}" Style="{StaticResource A_Style_FZTextBlock_HudMedium_BucketList}" MaxWidth="170" Margin="10,0,10,0"/>
                        </Grid>
                        <Grid HorizontalAlignment="Right" VerticalAlignment="Center" Width="156" Height="12" Margin="10,0,10,0">
                            <local:FZMaterial Color="{StaticResource A_Color_HUD_DamageBar_Background}"/>
                            <Grid HorizontalAlignment="Left" Width="{Binding Damage.Value, Converter={StaticResource A_LinearTransformConverter_MaxBarWidth}}" ClipToBounds="True">
                                <local:FZMaterial Color="{StaticResource A_Color_HUD_Text}" Width="156"/>
                            </Grid>
                        </Grid>
                    </Grid>
                </local:FZMaterial>
            </ControlTemplate>

            <Style TargetType="{x:Type FrameworkElement}"
                   BasedOn="{StaticResource A_Style_FrameworkElement_PillWidth}"
                x:Key="A_Style_Control_CurrentAndTarget">
                <Style.Triggers>
                    <MultiDataTrigger>
                        <MultiDataTrigger.Conditions>
                            <Condition Binding="{Binding ShowCurrent}" Value="False"/>
                            <Condition Binding="{Binding ShowTarget}" Value="False"/>
                        </MultiDataTrigger.Conditions>
                        <Setter Property="Visibility" Value="Collapsed"/>
                    </MultiDataTrigger>
                </Style.Triggers>
            </Style>

            <Style TargetType="{x:Type Control}"
                x:Key="A_Style_Control_TimeRemaining_NotCreate">
                <Setter Property="Visibility" Value="{Binding ChallengeType, RelativeSource={RelativeSource AncestorType=UserControl}, Converter={StaticResource A_MappingConverter_TimeRemaining_Visibility}}" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding ShowTimeRemaining}" Value="False">
                        <Setter Property="Visibility" Value="Collapsed"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <DataTemplate x:Key="A_DataTemplate_StandaloneChallenge">
                <ContentControl Template="{StaticResource A_Template_Control_HudInstruction}" 
                                Content="{Binding ChallengeText}" 
                                Visibility="{Binding ChallengeText, Converter={StaticResource A_StringVisConverter}}"
                                MaxWidth="{Binding ActualWidth, ElementName=PillsContainer}"
                                Margin="0,8,0,0"/>
            </DataTemplate>

            <local:MappingConverter x:Key="A_MappingConverter_SecondaryProgressVisibility" Default="{x:Static Visibility.Collapsed}">
                <local:MappingConverterEntry Key="{x:Static local:HUDChallengeType.MultiDestination}" Value="{x:Static Visibility.Visible}" />
            </local:MappingConverter>

            <NumUnitConverter x:Key="A_NumUnitConverter_SecondaryProgress" FractionDigits="0" ShowUnit="False"/>

            <ControlTemplate x:Key="A_ControlTemplate_ContentControl_SecondaryProgress" TargetType="ContentControl">
                <StackPanel Orientation="Horizontal">
                    <StackPanel Orientation="Horizontal" Style="{StaticResource A_Style_FrameworkElement_Challenge_DynamicTextContainer}">
                        <local:FZTextBlock Text="{Binding SecondaryProgressCurrent, Converter={StaticResource A_NumUnitConverter_SecondaryProgress}}" Style="{StaticResource A_Style_FZTextBlock_Challenge_ProgressText}" />
                        <local:FZTextBlock Text="/" Style="{StaticResource A_Style_FZTextBlock_Challenge_ProgressText}" />
                        <local:FZTextBlock Text="{Binding SecondaryProgressTarget, Converter={StaticResource A_NumUnitConverter_SecondaryProgress}}" Style="{StaticResource A_Style_FZTextBlock_Challenge_ProgressText}" />
                    </StackPanel>
                    <local:FZTextBlock Text="{Binding SecondaryProgressUnits}" Style="{StaticResource A_Style_FZTextBlock_Challenge_ProgressTitleText}" Margin="14,-0.5,0,0"/>
                </StackPanel>
            </ControlTemplate>

        </ResourceDictionary>
    </UserControl.Resources>

    <StackPanel x:Name="PART_LayoutRoot" Orientation="Vertical" VerticalAlignment="Top" HorizontalAlignment="Right" Width="625">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="VisualStateGroup">
                <VisualState x:Name="PART_Hidden">
                    <Storyboard>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PART_LayoutRoot">
                            <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                        </DoubleAnimationUsingKeyFrames>
                        <StringAnimationUsingKeyFrames Storyboard.TargetProperty="(local:EventFire.EventName)" Storyboard.TargetName="EventFire">
                            <DiscreteStringKeyFrame KeyTime="0:0:0.5" Value="HiddenComplete"/>
                        </StringAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="PART_Shown">
                    <Storyboard>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PART_LayoutRoot">
                            <EasingDoubleKeyFrame KeyTime="0" Value="1"/>
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>


        <StackPanel Orientation="Vertical" VerticalAlignment="Top" HorizontalAlignment="Left" x:Name="PillsContainer">
            <StackPanel Visibility="{Binding ChallengeTitle, Converter={StaticResource A_StringVisConverter}}">
                <Decorator RenderTransformOrigin="0.5,0.5" RenderTransform="{StaticResource A_SkewTransform_HUD_Italics}">
                    <local:FZTextBlock Text="{Binding ChallengeTitle, Converter={StaticResource A_StringToUpper}}" Color="{StaticResource A_Color_HUD_AlternateText}" Style="{StaticResource A_Style_FZTextBlock_HudMedium_BucketList}" TextWrapping="Wrap"/>
                </Decorator>
                <local:FZMaterial Height="1" Margin="0,16"/>
            </StackPanel>

            <ContentControl Template="{StaticResource A_ControlTemplate_ContentControl_SecondaryProgress}"
                            Visibility="{Binding ChallengeType, Converter={StaticResource A_MappingConverter_SecondaryProgressVisibility}}"
                            Margin="6,0,0,14"/>

            <StackPanel Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Top" Style="{StaticResource A_Style_FrameworkElement_PillWidth}" Visibility="{Binding SceneEnum, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_Converter_HUDSceneToVisibility_Default}}">
                <Control DataContext="{Binding TimeRemaining}" Template="{StaticResource A_ControlTemplate_Control_TimeRemaining}" Style="{StaticResource A_Style_Control_TimeRemaining_NotCreate}"/>
                <Control DataContext="{Binding MiniMissionTimeRemaining}" Template="{StaticResource A_ControlTemplate_Control_TimeRemaining}" Visibility="{Binding ShowMiniMissionItem, Converter={StaticResource A_FZBooleanToVisibilityConverter}, FallbackValue=Collapsed}"/>
                <StackPanel Style="{StaticResource A_Style_Control_CurrentAndTarget}" Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Top">
                    <Control Template="{StaticResource A_ControlTemplate_Control_Target}" Visibility="{Binding ShowTarget, Converter={FZBooleanToVisibilityConverter}}"/>
                    <Decorator Visibility="{Binding ShowCurrent, Converter={FZBooleanToVisibilityConverter}}">
                        <Control Template="{StaticResource A_ControlTemplate_Control_Current}" Visibility="{Binding ChallengeType, Converter={StaticResource A_MappingConverter_Current_Visibility}}"/>
                    </Decorator>
                    <Control Template="{StaticResource A_ControlTemplate_Control_Damage}" Visibility="{Binding ChallengeType, Converter={StaticResource A_MappingConverter_Damage_Visibility}}"/>
                    <Decorator Height="10"/>
                </StackPanel>
            </StackPanel>

            <StackPanel Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Top" Style="{StaticResource A_Style_FrameworkElement_PillWidth}" Visibility="{Binding SceneEnum, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_Converter_HUDSceneToVisibility_CreateFlow}}">
                <Control DataContext="{Binding TimeRemaining}" Template="{StaticResource A_ControlTemplate_Control_TimeRemaining}" />
                <StackPanel Style="{StaticResource A_Style_Control_CurrentAndTarget}" Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Top">
                    <Decorator Visibility="{Binding ShowCurrent, Converter={FZBooleanToVisibilityConverter}}">
                        <Control Template="{StaticResource A_ControlTemplate_Control_Current}" Visibility="{Binding ChallengeType, Converter={StaticResource A_MappingConverter_Current_Visibility_CreateFlow}}"/>
                    </Decorator>
                    <Control Template="{StaticResource A_ControlTemplate_Control_Damage}" Visibility="{Binding ChallengeType, Converter={StaticResource A_MappingConverter_Damage_Visibility}}"/>
                    <Decorator Height="10"/>
                </StackPanel>
                <Decorator Height="16"/>
            </StackPanel>

            <ContentControl Template="{StaticResource A_Template_Control_HudInstruction}" 
                Content="{Binding ChallengeObjective}" 
                Visibility="{Binding ChallengeObjective, Converter={StaticResource A_StringVisConverter}}"
                MaxWidth="{Binding ActualWidth, ElementName=PillsContainer}"
                Margin="0,4,0,0"/>

            <ItemsControl ItemsSource="{Binding StandaloneChallenges}"
                          ItemTemplate="{StaticResource A_DataTemplate_StandaloneChallenge}"
                          Focusable="False"
                          VerticalAlignment="Top"
                          HorizontalAlignment="Left" />

            <local:EventFire x:Name="EventFire"/>
        </StackPanel>
    </StackPanel>
</UserControl>
