<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:System="clr-namespace:System;assembly=mscorlib"
    xmlns:local="clr-namespace:ForzaUI">

    <!-- Styles -->
    <!-- The ScrollingTextBlock must never be in a StackPanel due to how that container measures height. A Grid will work.-->
    <Style x:Key="A_Style_ScrollingTextBlock" TargetType="{x:Type local:ScrollingTextBlock}">
        <Style.Resources>
            <!-- A dummy storyboard to have it not break in blend :) -->
            <Storyboard x:Key="TextScrollStory">
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>
        </Style.Resources>
        <Setter Property="Focusable" Value="False"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type local:ScrollingTextBlock}"> 
					<Grid x:Name="PART_ContentContainer">
						<ScrollViewer x:Name="PART_ScrollViewer" ScrollViewer.VerticalScrollBarVisibility="Hidden">
                            <local:FZTextBlock x:Name="PART_ContentText"
                                               Margin="0,0,0,15"
                                               Text="{TemplateBinding Text}"
                                               Style="{StaticResource A_Style_FZTextBlock_DescriptionBlockBody}"
                                               Color="{TemplateBinding Tag}"
                                               TextWrapping="Wrap"
                                               Stretch="None" />
                        </ScrollViewer>
    				</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
    </Style>

    <local:MappingConverter x:Key="A_Converter_BlammoTypeToText">
        <local:MappingConverterEntry Key="{x:Static local:MarketplaceBlammoType.Purchased}" Value="{local:Loc InGameMarketplace.IDS_Purchased}"/>
        <local:MappingConverterEntry Key="{x:Static local:MarketplaceBlammoType.Free}" Value="{local:Loc InGameMarketplace.IDS_Free}"/>
        <local:MappingConverterEntry Key="{x:Static local:MarketplaceBlammoType.OnSale}" Value="{local:Loc InGameMarketplace.IDS_OnSale}"/>
        <local:MappingConverterEntry Key="{x:Static local:MarketplaceBlammoType.New}" Value="{local:Loc InGameMarketplace.IDS_New}"/>
    </local:MappingConverter>

    <local:MappingConverter x:Key="A_Converter_BlammoTypeToVisibility" Default="{x:Static Visibility.Visible}">
        <local:MappingConverterEntry Key="{x:Static local:MarketplaceBlammoType.None}" Value="{x:Static Visibility.Collapsed}"/>
    </local:MappingConverter>

    <Style x:Key="A_Style_MarketplaceBlammo"
           TargetType="{x:Type ContentControl}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ContentControl}">
                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_CarSelectCarouselItem_StatusIconBackground}"
                                      Focusable="False"
                                      Color="{Binding Path=(local:BindingProxy.A), RelativeSource={RelativeSource TemplatedParent}}">
                        <local:FZTextBlock Text="{TemplateBinding Content}"
                                           Style="{StaticResource A_Style_FZTextBlock_CarSelectCarouseItem_StatusText}"
                                           Color="{Binding Path=(local:BindingProxy.B), RelativeSource={RelativeSource TemplatedParent}}" />
                    </local:FZMaterial>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        
        <Setter Property="FocusVisualStyle"
                Value="{x:Null}" />
        
        <Setter Property="local:BindingProxy.A"
                Value="{StaticResource A_Color_Tile_Notice}" />
        <Setter Property="local:BindingProxy.B"
                Value="{StaticResource A_Color_Header_Text}" />
        <Setter Property="Tag"
                Value="{x:Static local:MarketplaceBlammoType.None}" />
        
        <Style.Triggers>

            <Trigger Property="Tag"
                     Value="{x:Static local:MarketplaceBlammoType.Purchased}">
                <Setter Property="Content"
                        Value="{local:Loc InGameMarketplace.IDS_Purchased}" />
                <Setter Property="local:BindingProxy.A"
                        Value="{StaticResource A_Color_ItemStatusBackground}" />
            </Trigger>

            <Trigger Property="Tag"
                     Value="{x:Static local:MarketplaceBlammoType.Free}">
                <Setter Property="Content"
                        Value="{local:Loc InGameMarketplace.IDS_Free}" />
                <Setter Property="local:BindingProxy.A"
                        Value="{StaticResource A_Color_ItemStatusBackground}" />
            </Trigger>

            <Trigger Property="Tag"
                     Value="{x:Static local:MarketplaceBlammoType.OnSale}">
                <Setter Property="Content"
                        Value="{local:Loc InGameMarketplace.IDS_OnSale}" />
                <Setter Property="local:BindingProxy.A"
                        Value="{StaticResource A_Color_ItemStatusBackground_Sale}" />
            </Trigger>

            <Trigger Property="Tag"
                     Value="{x:Static local:MarketplaceBlammoType.New}">
                <Setter Property="Content"
                        Value="{local:Loc InGameMarketplace.IDS_New}" />
                <Setter Property="local:BindingProxy.A"
                        Value="{StaticResource A_Color_ItemStatusBackground}" />
            </Trigger>

            <Trigger Property="Tag"
                     Value="{x:Static local:MarketplaceBlammoType.None}">
                <Setter Property="Visibility"
                        Value="Collapsed" />
            </Trigger>

            <Trigger Property="Tag"
                     Value="{x:Null}">
                <Setter Property="Visibility"
                        Value="Collapsed" />
            </Trigger>
            
            <Trigger Property="Selector.IsSelected"
                     Value="True">
                <Setter Property="Panel.ZIndex"
                        Value="3" />
            </Trigger>
            
        </Style.Triggers>
    </Style>

    <Style x:Key="A_Style_MarketPlaceBlammoWithIcon"
       TargetType="{x:Type ContentControl}" BasedOn="{StaticResource A_Style_MarketplaceBlammo}">
        <Style.Resources>
            <Style x:Key="A_Style_BlammoIcon_Dynamic" TargetType="local:FZMaterial">
                <Setter Property="Visibility" Value="Collapsed"/>
            </Style>

            <Style x:Key="A_Style_BlammoText_Dynamic" TargetType="local:FZTextBlock" BasedOn="{StaticResource A_Style_FZTextBlock_CarSelectCarouseItem_StatusText}">
                <Setter Property="Margin" Value="50,0,12,0"/>
                <Setter Property="Color" Value="{Binding Path=(local:BindingProxy.B), RelativeSource={RelativeSource TemplatedParent}}"/>
            </Style>
        </Style.Resources>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ContentControl}">
                    <Grid>
                        <!--Blammo type in panel-->
                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_CarSelectCarouselItem_StatusIconBackground}" Height="44"
                                          Focusable="False" Color="{Binding Path=(local:BindingProxy.A), RelativeSource={RelativeSource TemplatedParent}}">
                            <Grid>
                                <!--Icon-->
                                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_HighlightShadow}">
                                    <local:FZMaterial Style="{DynamicResource A_Style_BlammoIcon_Dynamic}"/>
                                </local:FZMaterial>
                                <local:FZTextBlock Text="{TemplateBinding Content}"
                                                   Style="{DynamicResource A_Style_BlammoText_Dynamic}"/>
                            </Grid>
                        </local:FZMaterial>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="A_Style_Control_MarketplaceBlammoOwnedTick" TargetType="{x:Type Control}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Control}">
                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_CarSelectCarouselItem_StatusIconBackground}"
                                      Focusable="False">
                        <local:FZMaterial ImageSource="/ForzaUI;component/Textures/Anthem/Icons/Tick.png"/>
                    </local:FZMaterial>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Visibility" Value="Collapsed"/>
        <Style.Triggers>
            <Trigger Property="Tag" Value="{x:Static local:MarketplaceBlammoType.Purchased}">
                <Setter  Property="Visibility" Value="Visible"/>
            </Trigger>
        </Style.Triggers>
    </Style>
</ResourceDictionary>