Does an AddHandler require parameters?

774 views Asked by At

I'm trying to add a handler, but as soon as I'm targetting a method that has parameters, the handler fails. This is the simple code:

AddHandler App.Current.RootVisual.MouseLeftButtonUp, RootVisual_MouseLeftButtonUp

Private Sub RootVisual_MouseLeftButtonUp(ByVal sender As Object, ByVal e As MouseButtonEventArgs)

End Sub

This error won't let me build. When looking at the examples, I'm doing it right. This is the error I get:

Error 3 Argument not specified for parameter 'e' of 'Private Sub RootVisual_MouseLeftButtonUp(sender As Object, e As System.Windows.Input.MouseButtonEventArgs)'. C:\TFS\ProjectCollection\ItemManagementTool\ItemManagementTool.ClientApplication\Views\MainMenu.xaml.vb 82 70 ItemManagementTool.ClientApplication

I get a similar error for the "sender" parameter. Any ideas?

1

There are 1 answers

1
MichaelS On BEST ANSWER

You are missing the AddressOf keyword

AddHandler App.Current.RootVisual.MouseLeftButtonUp, AddressOf RootVisual_MouseLeftButtonUp