// If the routed event type matches one the element listening on then add handler to the event route. internal static void AddHandlerToRoute(DependencyObject o, EventRoute route, RoutedEventHandler eventHandler, bool handledToo) { // Add a synchronized input handler to the route. route.Add(o, eventHandler, handledToo); }
// This is a helper that will facilitate adding a given array of handlers to the route private static void AddStyleHandlersToEventRoute( EventRoute route, DependencyObject source, RoutedEventHandlerInfo[] handlers) { if (handlers != null) { for (int i=0; i<handlers.Length; i++) { route.Add(source, handlers[i].Handler, handlers[i].InvokeHandledEventsToo); } } }
/// <summary> /// Add the event handlers for this element to the route. /// </summary> public void AddToEventRoute(EventRoute route, RoutedEventArgs e) { if (route == null) { throw new ArgumentNullException("route"); } if (e == null) { throw new ArgumentNullException("e"); } // Get class listeners for this ContentElement RoutedEventHandlerInfoList classListeners = GlobalEventManager.GetDTypedClassListeners(this.DependencyObjectType, e.RoutedEvent); // Add all class listeners for this ContentElement while (classListeners != null) { for(int i = 0; i < classListeners.Handlers.Length; i++) { route.Add(this, classListeners.Handlers[i].Handler, classListeners.Handlers[i].InvokeHandledEventsToo); } classListeners = classListeners.Next; } // Get instance listeners for this ContentElement FrugalObjectList<RoutedEventHandlerInfo> instanceListeners = null; EventHandlersStore store = EventHandlersStore; if (store != null) { instanceListeners = store[e.RoutedEvent]; // Add all instance listeners for this ContentElement if (instanceListeners != null) { for (int i = 0; i < instanceListeners.Count; i++) { route.Add(this, instanceListeners[i].Handler, instanceListeners[i].InvokeHandledEventsToo); } } } // Allow Framework to add event handlers in styles AddToEventRouteCore(route, e); }
private static void AddStyleHandlersToEventRoute(EventRoute route, DependencyObject source, RoutedEventHandlerInfo[] handlers) { if (handlers == null) return; for (int index = 0; index < handlers.Length; ++index) route.Add((object) source, handlers[index].Handler, handlers[index].InvokeHandledEventsToo); }