简体   繁体   English

C# - 获取收听 RoutedEvent 的订阅者列表?

[英]C# - Get a list of subscribers listening to a RoutedEvent?

I'm trying to get a list of objects that are subscribing to the PasswordBox PasswordChanged event.我正在尝试获取订阅 PasswordBox PasswordChanged 事件的对象列表。

The PasswordBox has a static readonly RoutedEvent PasswordChangedEvent and an instance PasswordChanged event. PasswordBox 有一个 static 只读 RoutedEvent PasswordChangedEvent和一个实例PasswordChanged事件。

Thanks!谢谢!

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.注册PasswordChanged事件,修改PasswordBox值,然后验证使用提供的值调用了您的侦听器。

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.由于您有对控件的引用,因此尝试获取控件外部的订阅者列表会容易得多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM