コード例 #1
0
        private static void OnRoutedEventChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            string routedEvent = (string)e.NewValue;

            if (!string.IsNullOrEmpty(routedEvent))
            {
                EventHooker eventHooker = new EventHooker();
                eventHooker.ControlCommandObject = d;
                EventInfo eventInfo = GetEventInfo(d.GetType(), routedEvent);

                if (eventInfo != null)
                {
                    eventInfo.AddEventHandler(d, eventHooker.GetEventHandler(eventInfo));
                    //System.Runtime.InteropServices.WindowsRuntime.EventRegistrationTokenTable<RoutedEventArgs>
                    //Info: http://www.microsoft.com/en-us/download/details.aspx?id=29058
                    //var eventpattern = System.Reactive.Linq.Observable.FromEventPattern<RoutedEventArgs>(d, routedEvent);
                }

            }
        }
コード例 #2
0
        private static void OnExceptionRoutedEventChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            string routedEvent = (string)e.NewValue;

            if (!string.IsNullOrEmpty(routedEvent))
            {
                EventHooker eventHooker = new EventHooker();
                eventHooker.ControlCommandObject = d;
                EventInfo eventInfo = GetEventInfo(d.GetType(), routedEvent);

                if (eventInfo != null)
                {
                    eventInfo.AddEventHandler(d, eventHooker.GetEventHandler(eventInfo));
                }

            }
        }