UIElement.AddToEventRoute(EventRoute, RoutedEventArgs) Method

Definition

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

public:
 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)

Parameters

route
EventRoute

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

e
RoutedEventArgs

用于添加处理程序的事件数据。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.

Remarks

此方法可由内容宿主元素(实现 IContentHost 的元素或不是的元素)用于向 EventRoute中的子元素添加处理程序。This 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. 但是,在某些情况下,在模板树中混合使用 ContentElementUIElement 时,需要将来自模板的干预元素添加到路由中。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. ContentElementUIElement 都支持此方法的版本。Both ContentElement and UIElement support a version of this method.

Applies to