示例#1
0
        /// <summary>
        /// Sets the Command and CommandParameter properties to null.
        /// </summary>
        protected override void OnDetaching()
        {
            base.OnDetaching();

            this.Command          = null;
            this.CommandParameter = null;

            this.commandBehavior = null;
        }
示例#2
0
        private ExecutableCommandBehavior GetOrCreateBehavior()
        {
            // In case this method is called prior to this action being attached,
            // the CommandBehavior would always keep a null target object (which isn't changeable afterwards).
            // Therefore, in that case the behavior shouldn't be created and this method should return null.
            if (this.commandBehavior == null && this.AssociatedObject != null)
            {
                this.commandBehavior = new ExecutableCommandBehavior(this.AssociatedObject);
            }

            return(this.commandBehavior);
        }
示例#3
0
        private ExecutableCommandBehavior GetOrCreateBehavior(UIElement sender)
        {
            // In case this method is called prior to this action being attached,
            // the CommandBehavior would always keep a null target object (which isn't changeable afterwards).
            // Therefore, in that case the behavior shouldn't be created and this method should return null.
            if (_commandBehavior == null && sender != null)
            {
                _commandBehavior = new ExecutableCommandBehavior(sender);
            }

            _commandBehavior.Command          = Command;
            _commandBehavior.CommandParameter = CommandParameter;
            _commandBehavior.AutoEnable       = AutoEnable;

            return(_commandBehavior);
        }