Imports System.ComponentModel Imports System.Collections.ObjectModel Namespace Binding_to_a_Collection Public Class PatientBusinessLogic Public Function GetPatients() As ObservableCollection(Of Patient) Dim patients As New ObservableCollection(Of Patient)() Dim p As New Patient("David", 160, 70, 105, 70) patients.Add(p) p = New Patient("George", 145, 66, 111, 77) patients.Add(p) p = New Patient("John", 190, 71, 90, 60) patients.Add(p) Return patients End Function End Class Public Class 患者 Implements INotifyPropertyChanged Private patient_name As String Public Property Name() As String Get Return patient_name End Get Set(ByVal value As String) If patient_name <> value Then patient_name = value NotifyPropertyChanged("Name") End If End Set End Property Private patient_height As Integer Public Property Height() As Integer Get Return patient_height End Get Set(ByVal value As Integer) If patient_height <> value Then patient_height = value NotifyPropertyChanged("Height") End If End Set End Property Private patient_weight As Integer Public Property Weight() As Integer Get Return patient_weight End Get Set(ByVal value As Integer) If patient_weight <> value Then patient_weight = value NotifyPropertyChanged("Weight") End If End Set End Property Private patient_systolic_pressure As Integer Public Property SystolicPressure() As Integer Get Return patient_systolic_pressure End Get Set(ByVal value As Integer) If patient_systolic_pressure <> value Then patient_systolic_pressure = value NotifyPropertyChanged("SystolicPressure") End If End Set End Property Private patient_diastolic_pressure As Integer Public Property DiastolicPressure() As Integer Get Return patient_diastolic_pressure End Get Set(ByVal value As Integer) If patient_diastolic_pressure <> value Then patient_diastolic_pressure = value NotifyPropertyChanged("DiastolicPressure") End If End Set End Property Public Sub New(ByVal name As String, ByVal weight As Integer, ByVal height As Integer, ByVal systolicPressure As Integer, ByVal diastolicPressure As Integer) Me.Name = name Me.Weight = weight Me.Height = height Me.SystolicPressure = systolicPressure Me.DiastolicPressure = diastolicPressure End Sub #Region "INotifyPropertyChanged Members" Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged #End 地域 Private Sub NotifyPropertyChanged(ByVal PropertyName As String) RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName)) End Sub End Class End Namespace