Imports System.ComponentModel

Public Class ColDatos
  Implements INotifyPropertyChanged
  Public Sub New()
    ObtenerTelefonos()
  End Sub

  Private m_colTelefonos As Telefonos
  Public Property ColTelefonos() As Telefonos
    Get
      Return m_colTelefonos
    End Get
    Set(value As Telefonos)
      m_colTelefonos = value
      OnPropertyChanged(New PropertyChangedEventArgs("ColTelefonos"))
    End Set
  End Property

  Public Event PropertyChanged As PropertyChangedEventHandler _
    Implements INotifyPropertyChanged.PropertyChanged
  Public Sub OnPropertyChanged(e As PropertyChangedEventArgs)
    RaiseEvent PropertyChanged(Me, e) ' generar evento
  End Sub

  ' Crear la base de datos
  Private Function ObtenerTelefonos() As Telefonos
    m_colTelefonos = New Telefonos()
    Dim prefijo As Integer = 636
    For i As Integer = 1 To 29
      Dim nom As String = "Persona " & String.Format("{0:D3}", i)
      Dim dir As String = "Dirección " & String.Format("{0:D3}", i)
      Dim tel As String = prefijo & "333" & String.Format("{0:D3}", i)
      Dim obs As String = "Observación" & String.Format("{0:D3}", i)
      If i Mod 10 = 0 Then
        prefijo += 10
      End If
      m_colTelefonos.Add(New Telefono(i, nom, dir, tel, obs))
    Next
    Return m_colTelefonos
  End Function
End Class
