<UserControl x:Class="ApSilverlightTfnos.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:local="clr-namespace:ApSilverlightTfnos"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Width="480" Height="360" VerticalContentAlignment="Top"
    Loaded="UserControl_Loaded"
    MouseLeftButtonDown="popInfo_MouseLeftButtonDown">
  <Grid x:Name="LayoutRoot" >
    <Grid.Resources>
      <local:ConversorBytes_ImageSource x:Key="conversorBytes_ImageSource"/>
    </Grid.Resources>
    <Grid.ColumnDefinitions>
      <ColumnDefinition />
      <ColumnDefinition />
      <ColumnDefinition />
      <ColumnDefinition />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
      <RowDefinition />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <Grid.Background>
      <ImageBrush ImageSource="/ApSilverlightTfnos;component/Recursos/telefono.jpg" />
    </Grid.Background>
    <!-- Título -->
    <sdk:Label Grid.ColumnSpan="3"
         Style="{StaticResource EstiloTextoCabecera}">
      Lista de teléfonos
    </sdk:Label>

    <sdk:Label Grid.Column="0" Grid.Row="1" Content="Lista por apellido 1:" Margin="5"/>
    <sdk:Label Grid.Column="0" Grid.Row="2" Content="Foto:" Margin="5"/>
    <sdk:Label Grid.Column="0" Grid.Row="3" Content="Nombre y apellidos:" Style="{StaticResource EstiloLabel}" />
    <sdk:Label Grid.Column="0" Grid.Row="4" Content="Dirección:" Style="{StaticResource EstiloLabel}" />
    <sdk:Label Grid.Column="0" Grid.Row="5" Content="Teléfono:" Style="{StaticResource EstiloLabel}" />
    <sdk:Label Grid.Column="0" Grid.Row="6" Content="Observaciones:"  Style="{StaticResource EstiloLabel}" />

    <!-- Lista de personas -->
    <ComboBox Name="lstPersonas" Grid.Column="1" Grid.Row="1"
           Style="{StaticResource EstiloComboBox}" SelectionChanged="lstPersonas_SelectionChanged">
      <ComboBox.ItemTemplate>
        <DataTemplate>
          <TextBlock Text="{Binding apellido1}" />
        </DataTemplate>
      </ComboBox.ItemTemplate>
    </ComboBox>

    <Image Name="imFoto" Grid.Column="1" Grid.Row="2"
           Style="{StaticResource EstiloImagen}"
           Source="{Binding Path=foto, Mode=TwoWay,
           Converter={StaticResource conversorBytes_ImageSource}}"
           MouseLeftButtonDown="imFoto_MouseLeftButtonDown" />
    <TextBox Name="ctNombre" Grid.Column="1" Grid.Row="3"
             Style="{StaticResource EstiloTextBox}"
             Text="{Binding Path=nombre, Mode=TwoWay}" />
    <TextBox Name="ctApellido1" Grid.Column="2" Grid.Row="3"
             Style="{StaticResource EstiloTextBox}"
             Text="{Binding Path=apellido1, Mode=TwoWay}" />
    <TextBox Name="ctApellido2" Grid.Column="3" Grid.Row="3"
             Style="{StaticResource EstiloTextBox}"
             Text="{Binding Path=apellido2, Mode=TwoWay}" />
    <TextBox Name="ctDireccion" Grid.Column="1" Grid.Row="4"
             Grid.ColumnSpan="2" Style="{StaticResource EstiloTextBox}"
             Text="{Binding Path=direccion, Mode=TwoWay}"/>
    <TextBox Name="ctTelefono" Grid.Column="1" Grid.Row="5"
             Style="{StaticResource EstiloTextBox}"
             Text="{Binding Path=telefono1, Mode=TwoWay}"/>
    <TextBox Name="ctObservaciones" Grid.Column="1" Grid.Row="6"
             Grid.ColumnSpan="2" Style="{StaticResource EstiloTextBox}"
             Text="{Binding Path=observaciones, Mode=TwoWay}"/>

    <StackPanel Grid.ColumnSpan="4" Grid.Row="7"
                Style="{StaticResource EstiloStackPanel}">
      <Button Name="btActualizar" Content="Actualizar"
              Style="{StaticResource EstiloButton}" Click="btActualizar_Click" />
      <Button Name="btAñadir" Content="Añadir"
              Style="{StaticResource EstiloButton}" Click="btAgregar_Click" />
      <Button Name="btBorrar" Content="Borrar"
              Style="{StaticResource EstiloButton}" Click="btBorrar_Click" />
    </StackPanel>
    <Popup x:Name="popInfo" Grid.Column="2" Grid.Row="1"
           Grid.ColumnSpan="2" VerticalOffset="6">
      <Border MouseLeftButtonDown="popInfo_MouseLeftButtonDown" Background="Lavender">
        <TextBlock Name="tbkInfo" Style="{StaticResource EstiloTextBlock}" />
      </Border>
    </Popup>
  </Grid>
</UserControl>
