0

I have to add event setter to a style in code behind file in VB.NET.

While adding event setter we have to pass 2 arguments.

  1. is system.windows.routedevent
  2. system.delegate.

I am unable to pass system.delegate.

1 Answer 1

0

You need to define a Delegate with the correct signature first:

Delegate Sub HandlerDelegate(ByVal sender As Object, ByVal e As RoutedEventArgs)

Then create a method in your class matching that signature

Private Sub MyHandler(ByVal sender As Object, ByVal e As RoutedEventArgs)

End Sub

Now you can define a variable of HandlerDelegate type, assign your method to it and pass it to EventSetter constructor:

Dim handler As HandlerDelegate
handler = AddressOf Me.MyHandler

Dim setter As EventSetter
setter = New EventSetter(routedEvent, handler)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.