예제 #1
0
        /// <inheritdoc />
        public override void Attach(FrameworkElement obj)
        {
            base.Attach(obj);

            if (!string.IsNullOrEmpty(this.EventName))
            {
                var eventHooker = new EventHooker(this);
                eventHooker.HookEvent(obj, this.EventName);
            }
        }
        /// <summary>
        /// Hooks an event on the target object.
        /// </summary>
        /// <param name="eventName">
        /// The event name.
        /// </param>
        /// <param name="targetObj">
        /// The source object.
        /// </param>
        protected void HookEvent(string eventName, object targetObj)
        {
            if (!string.IsNullOrEmpty(eventName))
            {
                var target = this.GetEventTarget(targetObj);

                if (target != null)
                {
                    var eventHooker = new EventHooker(this);
                    eventHooker.HookEvent(target, eventName);

                    this.hookedEvent = new WeakReference<EventHooker>(eventHooker);
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Hooks an event on the target object.
        /// </summary>
        /// <param name="eventName">
        /// The event name.
        /// </param>
        /// <param name="targetObj">
        /// The source object.
        /// </param>
        protected void HookEvent(string eventName, object targetObj)
        {
            if (!string.IsNullOrEmpty(eventName))
            {
                var target = this.GetEventTarget(targetObj);

                if (target != null)
                {
                    var eventHooker = new EventHooker(this);
                    eventHooker.HookEvent(target, eventName);

                    this.hookedEvent = new WeakReference <EventHooker>(eventHooker);
                }
            }
        }