public EventToCommandBinding(IEventBinding <TSource, TTarget, TEventArgs> binding, Expression <Func <TSource, TCommand> > commandExpression, Expression <Func <TTarget, bool> > canExecuteTargetPropertyExpression = null) :
            base(binding)
        {
            Check.NotNull(commandExpression, nameof(commandExpression));

            this.getCommand     = commandExpression.Compile();
            this.sourceRootNode = commandExpression.AsObservedNode();
            this.sourceRootNode.Observe(this.Source, this.WhenCommandChanged);

            if (canExecuteTargetPropertyExpression != null)
            {
                this.canExecuteTargetProperty = canExecuteTargetPropertyExpression.GetBindingExpression(this.Target);
                this.WhenCommandChanged();
            }
        }
示例#2
0
 public override void Dispose()
 {
     this.sourceRootNode.Unobserve();
     this.sourceRootNode = null;
     base.Dispose();
 }