UIElement.AddToEventRoute(EventRoute, RoutedEventArgs) 方法


将处理程序添加到当前 EventRoute 事件处理程序集合的指定 UIElement 中。Adds handlers to the specified EventRoute for the current UIElement event handler collection.

 void AddToEventRoute(System::Windows::EventRoute ^ route, System::Windows::RoutedEventArgs ^ e);
public void AddToEventRoute (System.Windows.EventRoute route, System.Windows.RoutedEventArgs e);
member this.AddToEventRoute : System.Windows.EventRoute * System.Windows.RoutedEventArgs -> unit
Public Sub AddToEventRoute (route As EventRoute, e As RoutedEventArgs)



要向其添加处理程序的事件路由。The event route that handlers are added to.


用于添加处理程序的事件数据。The event data that is used to add the handlers. 此方法使用事件数据的 RoutedEvent 属性创建处理程序。This method uses the RoutedEvent property of the event data to create the handlers.


此方法可由内容宿主元素使用, (实现的元素 IContentHost 或不) 为将子元素的处理程序添加到中的元素 EventRouteThis method can be used by content host elements (either those that implement IContentHost or those that don't) to add handlers for child elements to the EventRoute. 通常情况下,这并不是必需的 UIElement ,因为对已完成的逻辑树中的所有元素自动添加了处理程序。Ordinarily, this is not required for UIElement, because handlers are automatically added for all elements found in a completed logical tree. 但是,在某些情况下,在模板 ContentElement UIElement 树中混合使用和时,需要将来自模板的干预元素添加到路由。However, in some cases where ContentElement and UIElement are mixed in templated trees, intervening elements that came from the template need to be added to a route. ContentElement和都 UIElement 支持此方法的版本。Both ContentElement and UIElement support a version of this method.