Beispiel #1
0
        private IEnumerable <EventRouteItem> GetEventRouteItems(RoutedEvent routedEvent, UIElement originalSource, UIElement logicalSource)
        {
            IEnumerable <EventRouteItem> items = GetRoutedEventHandlers(routedEvent).Select(handler => new EventRouteItem(handler, originalSource, logicalSource, this));

            if (routedEvent.RoutingStrategy == RoutingStrategy.Bubble ||
                routedEvent.RoutingStrategy == RoutingStrategy.Tunnel)
            {
                UIElement visualParent = VisualParent as UIElement;

                if (visualParent != null)
                {
                    IEnumerable <EventRouteItem> parentItems = visualParent.GetEventRouteItems(routedEvent, originalSource, LogicalParent != visualParent ? visualParent : logicalSource);

                    if (routedEvent.RoutingStrategy == RoutingStrategy.Bubble)
                    {
                        items = items.Concat(parentItems);
                    }
                    else
                    {
                        items = parentItems.Concat(items);
                    }
                }
            }

            return(items.ToArray());
        }