为 RoutedEvent 创建自定义事件处理程序
给定一个路由事件标识符。
可以使用反射为该事件创建处理程序吗? (当然,在处理程序中添加一些代码)。
Given a routed event identifier.
It is posible using reflection to create a Handler for that event?? (and of course add some code inside the handler).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Silverlight 中真正的路由事件数量非常有限,它们都在
UIElement
上定义(FrameworkElement
上的Loaded
除外)。如果您引用的是其中之一,那么比使用反射更容易将提供的 RoutedEvent 对象与这几个已知的对象之一进行比较。一旦建立,您将知道使用有限数量的可能签名中的哪一个。
There are only very limited number of truely Routed Events in Silverlight, they are all defined on the
UIElement
(except forLoaded
on theFrameworkElement
).If its one of these to which you refer then rather than using reflection it would be easier to simply compare the provided
RoutedEvent
object with one of these few known ones. Once established you will know which of the a limited number of possible signatures to use.不确定这是否是您正在寻找的,但是您是否研究过 Func 和 Action 委托?
Not sure if this is what you are looking for, but have you looked into Func and Action delegates?