public static void AddEventHandler(DependencyObject element, RoutedEvent routedEvent, Delegate handler)
        {
            UIElement uiElement = element as UIElement;

            if (uiElement != null)
            {
                uiElement.AddHandler(routedEvent, handler);
            }
            else
            {
                ContentElement contentElement = element as ContentElement;
                if (contentElement != null)
                {
                    contentElement.AddHandler(routedEvent, handler);
                }
                else
                {
                    UIElement3D uiElement3d = element as UIElement3D;
                    if (uiElement3d != null)
                    {
                        uiElement3d.AddHandler(routedEvent, handler);
                    }
                }
            }
        }
Example #2
0
        public static void AddHandler(this DependencyObject element, RoutedEvent routedEvent, Delegate handler)
        {
            Debug.Assert(element != null, "Element must not be null");
            Debug.Assert(routedEvent != null, "RoutedEvent must not be null");

            UIElement uiElement = element as UIElement;

            if (uiElement != null)
            {
                uiElement.AddHandler(routedEvent, handler);
            }
            else
            {
                ContentElement contentElement = element as ContentElement;
                if (contentElement != null)
                {
                    contentElement.AddHandler(routedEvent, handler);
                }
                else
                {
                    UIElement3D uiElement3D = element as UIElement3D;
                    if (uiElement3D != null)
                    {
                        uiElement3D.AddHandler(routedEvent, handler);
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// A static helper method that adds a handler for a routed event
        /// to a target UIElement or ContentElement.
        /// </summary>
        /// <param name="element">UIElement or ContentElement that listens to the event</param>
        /// <param name="routedEvent">Event that will be handled</param>
        /// <param name="handler">Event handler to be added</param>
        internal static void AddHandler(DependencyObject element, RoutedEvent routedEvent, Delegate handler)
        {
            UIElement uie = element as UIElement;

            if (uie != null)
            {
                uie.AddHandler(routedEvent, handler);
            }
            else
            {
                ContentElement ce = element as ContentElement;
                ce?.AddHandler(routedEvent, handler);
            }
        }
Example #4
0
        internal static void smethod_1(DependencyObject dependencyObject_0, RoutedEvent routedEvent_0, Delegate delegate_0)
        {
            UIElement element = dependencyObject_0 as UIElement;

            if (element != null)
            {
                element.AddHandler(routedEvent_0, delegate_0);
            }
            else
            {
                ContentElement element2 = dependencyObject_0 as ContentElement;
                if (element2 != null)
                {
                    element2.AddHandler(routedEvent_0, delegate_0);
                }
            }
        }