UIElement.AddToEventRoute(EventRoute, RoutedEventArgs) 方法

定義

針對目前的 EventRoute 事件處理常式集合,將處理常式加入至指定的 UIElement

C#
public void AddToEventRoute (System.Windows.EventRoute route, System.Windows.RoutedEventArgs e);

參數

route
EventRoute

加入處理常式的事件路由。

e
RoutedEventArgs

用於加入處理常式的事件資料。 這個方法會使用事件資料的 RoutedEvent 屬性來建立處理常式。

備註

這個方法可由內容主元素使用, (實 IContentHost 作的元素,或是未) 的元素,將子專案的處理常式新增至 EventRoute 。 一般而言,不需要這樣做 UIElement ,因為處理常式會自動新增至已完成邏輯樹狀結構中找到的所有元素。 不過,在某些情況下 ContentElement ,範本化樹狀結構中有 和 UIElement 混合,需要將來自範本的中間元素新增至路由。 和 UIElementContentElement 支援這個方法的版本。

適用於

產品 版本
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
Windows Desktop 3.0, 3.1, 5, 6, 7