/// <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; }
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); }
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); }