How can I make an event that is raised when a variable or property is changed (or can I just put the code I would put in an event in the Set section of a property?
See Question&Answers more detail:osHow can I make an event that is raised when a variable or property is changed (or can I just put the code I would put in an event in the Set section of a property?
See Question&Answers more detail:osFrom the MSDN library entry INotifyPropertyChanged.PropertyChanged Event
:
Public Class DemoCustomer
Implements INotifyPropertyChanged
Private customerNameValue As String = String.Empty
Public Event PropertyChanged As PropertyChangedEventHandler _
Implements INotifyPropertyChanged.PropertyChanged
Private Sub NotifyPropertyChanged(ByVal info As String)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(info))
End Sub
Public Property CustomerName() As String
Get
Return Me.customerNameValue
End Get
Set(ByVal value As String)
If Not (value = customerNameValue) Then
Me.customerNameValue = value
NotifyPropertyChanged("CustomerName")
End If
End Set
End Property
End Class