Exemplo n.º 1
0
        /// <summary>
        /// Change handler for the event name
        /// </summary>
        /// <param name="dpo">VMTrigger object</param>
        /// <param name="e">EventArgs</param>
        private static void OnTargetChanged(DependencyObject dpo, DependencyPropertyChangedEventArgs e)
        {
            ViewModelTrigger vmt = (ViewModelTrigger)dpo;

            if (string.IsNullOrEmpty(vmt.EventName))
            {
                return;
            }

            object oldTarget = e.OldValue;

            if (oldTarget != null)
            {
                vmt.UnregisterEvent(oldTarget, vmt.EventName);
            }
            vmt.RegisterEvent(vmt.Target, vmt.EventName);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Change handler for the event name
        /// </summary>
        /// <param name="dpo">VMTrigger object</param>
        /// <param name="e">EventArgs</param>
        private static void OnEventNameChanged(DependencyObject dpo, DependencyPropertyChangedEventArgs e)
        {
            ViewModelTrigger vmt = (ViewModelTrigger)dpo;

            if (vmt.Target == null)
            {
                return;
            }

            string oldEventName = e.OldValue as string;

            if (!string.IsNullOrEmpty(oldEventName))
            {
                vmt.UnregisterEvent(vmt.Target, oldEventName);
            }
            vmt.RegisterEvent(vmt.Target, vmt.EventName);
        }