<?xml version="1.0" encoding="utf-8"?>
<UserControl x:Class="GeoDashboard.TapestryTile" Width="254" Height="177" Margin="6" Foreground="White" FontFamily="Segoe UI" FontSize="24" FontWeight="Light" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:c1="http://schemas.componentone.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:GeoDashboard">

  <Grid x:Name="LayoutRoot" Background="Black" DataContext="{Binding Path=Sources[USA_Tapestry]}">

    <Grid.Resources>
      <local:TapestryDescriptionConverter x:Key="_cvtTapestry" />
    </Grid.Resources>

    <Grid.RowDefinitions>
      <RowDefinition Height="auto" />
      <RowDefinition />
    </Grid.RowDefinitions>

    <Border Style="{StaticResource _tileCaption}">
      <StackPanel Orientation="Horizontal">
        <TextBlock Text="{Binding Dictionary[NAME].Value}" FontSize="12" Foreground="Black" />
        <TextBlock Text=", " FontSize="12" Foreground="Black" />
        <TextBlock Text="{Binding Dictionary[ST_ABBREV].Value}" FontSize="12" Foreground="Black" />
      </StackPanel>
    </Border>

    <!-- alternate between main and detail views -->
    <local:TransitionPanel x:Name="_transPanel" SelectedIndex="0" Grid.Row="1" Margin="12 0 12 6">

      <!-- main display -->
      <StackPanel>
        <TextBlock Text="The dominant tapestry is" TextWrapping="Wrap" />
        <TextBlock Text="{Binding Dictionary[TAPSEGNAM].Value}" FontWeight="Bold" TextWrapping="Wrap" Foreground="{StaticResource _brResult}" />
      </StackPanel>

      <!-- detail display -->
      <StackPanel>
        <TextBlock Text="{Binding Dictionary[TAPSEGNAM].Value}" FontWeight="Bold" TextWrapping="Wrap" Foreground="{StaticResource _brResult}" />
        <TextBlock Text="{Binding Dictionary[DOMTAP].Value, Converter={StaticResource _cvtTapestry}}" FontSize="12" TextWrapping="Wrap" />
      </StackPanel>
    </local:TransitionPanel>

    <!-- button to flip panel -->
    <HyperlinkButton Content="..." FontSize="12" Grid.Row="1" Margin="6" Command="{Binding SwitchPanelCommand, ElementName=_transPanel}" VerticalAlignment="Bottom" HorizontalAlignment="Right" />
  </Grid>
</UserControl>