UIElement.AddToEventRoute(EventRoute, RoutedEventArgs) 方法


針對目前的 EventRoute 事件處理常式集合,將處理常式加入至指定的 UIElementAdds 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.