public virtual void FireEvent(string eventName, RoutingStrategyEnum routingStrategy) { if (routingStrategy == RoutingStrategyEnum.Tunnel) { // Tunnel strategy: All parents first, then this element UIElement parent = VisualParent as UIElement; if (parent != null) { parent.FireEvent(eventName, routingStrategy); } } UIEventDelegate dlgt = EventOccured; if (dlgt != null) { dlgt(eventName); } switch (routingStrategy) { case RoutingStrategyEnum.Bubble: // Bubble strategy: First this element, then all parents UIElement parent = VisualParent as UIElement; if (parent != null) { parent.FireEvent(eventName, routingStrategy); } break; case RoutingStrategyEnum.VisualTree: // VisualTree strategy: First this element, then all children foreach (UIElement child in GetChildren()) { child.FireEvent(eventName, routingStrategy); } break; } }