Terry
Terry

Reputation: 5282

Does an AddHandler require parameters?

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?

Upvotes: 1

Views: 779

Answers (1)

MichaelS
MichaelS

Reputation: 7123

You are missing the AddressOf keyword

AddHandler App.Current.RootVisual.MouseLeftButtonUp, AddressOf RootVisual_MouseLeftButtonUp

Upvotes: 3

Related Questions