/// <summary>
        /// Handles changes to the Command property.
        /// </summary>
        private static void OnCommandChanged(
            DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var newCmd = (ICommand)e.NewValue;
            var uiElem = d as UIElement;

            if (uiElem != null)
            {
                // make sure the DepObjInfo object exists. Store in ObjInfo property.
                var objInfo = DepObjInfo.AssureObjInfo(d);

                // hook or unhook the MouseLeave event on this UIElement.
                // store the event handler in te DepObjInfo object that stored the DepObj itself.
                if (newCmd == null)
                {
                    uiElem.MouseLeave -= objInfo.MouseLeave;
                }
                else
                {
                    uiElem.MouseLeave += objInfo.MouseLeave;
                }
            }
        }