这是我的示例代码:
Public Class Parent
Private _TestProperty As String
Private WithEvents _Child As IList(Of Child)
Public Property Test() As String
Get
Return _TestProperty
End Get
Set(ByVal value As String)
_TestProperty = value
End Set
End Property
Public Property Child() As IList(Of Child)
Get
Return _Child
End Get
Set(ByVal value As IList(Of Child))
_Child = value
End Set
End Property
Private Sub eventHandler Handles _Child
End Class
Public Class Child
Private _TestProperty As String
Public Event PropertyChanged As EventHandler
Friend Sub Notify()
RaiseEvent PropertyChanged(Me, New EventArgs())
End Sub
Public Property Test() As String
Get
Return _TestProperty
End Get
Set(ByVal value As String)
_TestProperty = value
Notify()
End Set
End Property
End Class
我如何处理由父对象中的一个孩子引发的事件?在 _child 对象上使用 withevents 只会给我来自 List(of T) 对象的事件。
蒂亚