1

I'm trying to get a list of objects that are subscribing to the PasswordBox PasswordChanged event.

The PasswordBox has a static readonly RoutedEvent PasswordChangedEvent and an instance PasswordChanged event.

Thanks!

michael
  • 14,844
  • 28
  • 89
  • 177
  • 1
    To what end? Surely the point of events (in most event-based models) is that you don't care how many listeners there are, what they're doing with the information, etc. – Damien_The_Unbeliever May 24 '11 at 14:00
  • Unit Testing... I want to ensure that that my object is listening to the event. :) – michael May 24 '11 at 14:18
  • Think of it another way. Register for the PasswordChanged event, modify the PasswordBox value, verify your listener was called. Much simpler then trying to get the list of subscribers external to the control. – Aaron McIver May 24 '11 at 14:24
  • @Aaron, that's actually a good suggestion and works in this situation. Thanks. You should place it as an answer so I can accept it. – michael May 24 '11 at 16:34

1 Answers1

1

Perhaps you can look at this a different way.

Register for the PasswordChanged event, modify the PasswordBox value, then verify your listener was called with the provided value.

Since you have a reference to the control this will be much easier then attempting to acquire the list of subscribers external to the control.

Aaron McIver
  • 24,527
  • 5
  • 59
  • 88