Hi, Does someone know how to remove a handler set up by a lambda expression? According to this MSDN article, lambda expression should be assigned to variables which should be used to define handler operators. So far, I have used lambda expessions w/o variables. For instance, the following works:
Private Sub ScaleObjectInit1(ByVal objSrc As NumericUpDown, ByVal objTgt As FrameworkElement)
...
AddHandler Me.upDnScale.ValueChanged, Sub(sender As Object, e As Object) ScaleObject1(sender, e, objTgt)
End Sub
Private Sub ScaleObject1(ByVal sender As Object, ByVal e As Object, ByVal objTgt As FrameworkElement)
....
End Sub
Removing this handler via the following raises a compiler error as explained in the MSDN ref:
RemoveHandler Me.upDnScale.ValueChanged, Sub(sender As Object, e As Object) ScaleObject1(sender, e, objTgt) ' Does not work
I tried the following to no avail:
Event ProcessScale(ByVal sender As Object, ByVal e As Object, ByVal el As FrameworkElement)
Dim ScaleHandler As ProcessScaleEventHandler
..
AddHandler ProcessScale, ScaleHandler ' Does not work
AddHandler Me.upDnScale.ValueChanged, ScaleHandler ' Raises signature conflict
Any ideas would be greatly appreciated. TIA.
Private Sub ScaleObjectInit1(ByVal objSrc As NumericUpDown, ByVal objTgt As FrameworkElement)
...
AddHandler Me.upDnScale.ValueChanged, Sub(sender As Object, e As Object) ScaleObject1(sender, e, objTgt)
End Sub
Private Sub ScaleObject1(ByVal sender As Object, ByVal e As Object, ByVal objTgt As FrameworkElement)
....
End Sub
Removing this handler via the following raises a compiler error as explained in the MSDN ref:
RemoveHandler Me.upDnScale.ValueChanged, Sub(sender As Object, e As Object) ScaleObject1(sender, e, objTgt) ' Does not work
I tried the following to no avail:
Event ProcessScale(ByVal sender As Object, ByVal e As Object, ByVal el As FrameworkElement)
Dim ScaleHandler As ProcessScaleEventHandler
..
AddHandler ProcessScale, ScaleHandler ' Does not work
AddHandler Me.upDnScale.ValueChanged, ScaleHandler ' Raises signature conflict
Any ideas would be greatly appreciated. TIA.