Imports BaseDeDatos

Public Class DlgDataGrid
  Private azulClaro As New SolidColorBrush(Colors.LightSkyBlue)
  Private colorPredeterminado As New SolidColorBrush(Colors.White)

  Private Sub dgAlumnos_LoadingRow(sender As Object, e As DataGridRowEventArgs)
    ' Comprobar los datos de esta fila
    Dim filaActual As Alumno = TryCast(e.Row.DataContext, Alumno)
    If filaActual Is Nothing Then Return
    If filaActual.BecaAlumno = True Then
      e.Row.Background = azulClaro
    Else
      ' Restaurar el color predeterminado para asegurar que
      ' las filas recargadas con formato son restauradas
      e.Row.Background = colorPredeterminado
    End If
  End Sub

  Private Sub dgAlumnos_SelectedCellsChanged(sender As Object, e As SelectedCellsChangedEventArgs)
    CollectionViewSource.GetDefaultView(dgAlumnos.ItemsSource).Refresh()
  End Sub
End Class
