1

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?

Terry
  • 5,132
  • 4
  • 33
  • 66

1 Answers1

3

You are missing the AddressOf keyword

AddHandler App.Current.RootVisual.MouseLeftButtonUp, AddressOf RootVisual_MouseLeftButtonUp
MichaelS
  • 7,023
  • 10
  • 51
  • 75
  • Appreciated this question and answer. Thought I would add that I was making the mistake of having parenthesis at the end, i.e. RootVisual_MouseLeftButtonUp(). It doesn't like that, of course, but you don't know until you see it, as posted here. Thanks! – Alan Jan 27 '17 at 19:25