<Window x:Class="DlgDataGrid"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Diálogo DataGrid" Height="300" Width="400">
  <Window.Resources>
    <!-- Plantillas para configura la sección de detalles de las filas del DataGrid -->
    <!-- PLANTILLA ASIGNATURA -->
    <DataTemplate x:Key="kAsignatura">
      <WrapPanel>
        <TextBlock Text="{Binding Path=NomAsignatura}" Padding="2" />
        <TextBlock Text=":   " />
        <TextBox Text="{Binding Path=Nota}" Padding="2" />
      </WrapPanel>
    </DataTemplate>
    <!-- PLANTILLA ASIGNATURAS -->
    <HierarchicalDataTemplate x:Key="kAsignaturas"
                              ItemsSource="{Binding Path=ListaAsignaturas}"
                              ItemTemplate="{StaticResource kAsignatura}">
      <TextBlock Text="{Binding Path=Tipo}" Padding="2" />
    </HierarchicalDataTemplate>
  </Window.Resources>

  <Grid DataContext="{StaticResource objBBDD}" >
    <DataGrid Name="dgAlumnos" Margin="5"
              AutoGenerateColumns="False"
              ItemsSource="{Binding Path=Alumnos}"
              LoadingRow="dgAlumnos_LoadingRow" SelectedCellsChanged="dgAlumnos_SelectedCellsChanged">
      <DataGrid.Columns>
        <DataGridTextColumn Header="Nombre" Binding="{Binding Path=NomAlumno}"/>
        <DataGridTextColumn Header="Dirección" Binding="{Binding Path=DirAlumno}"/>
        <DataGridTextColumn Header="Estudios" Binding="{Binding Path=EstAlumno}"/>
        <DataGridCheckBoxColumn Header="Beca" Binding="{Binding Path=BecaAlumno}"/>
      </DataGrid.Columns>
      <!-- Sección de detalles de la fila -->
      <DataGrid.RowDetailsTemplate>
        <DataTemplate>
          <Border BorderThickness="0" Background="BlanchedAlmond" Padding="5">
            <TreeView  Name="trvAlumnos" Margin="5"
               ItemsSource="{Binding Path=ListaCoAsignaturas}"
               ItemTemplate="{StaticResource kAsignaturas}">
            </TreeView>
          </Border>
        </DataTemplate>
      </DataGrid.RowDetailsTemplate>
    </DataGrid>
  </Grid>
</Window>
