Esempio n. 1
0
        /// <summary>
        /// Binds an <see cref="IAction"/> instance to the <paramref name="actionProperty"/> and
        /// <paramref name="actionEvent"/> on the target object, via the specified <see cref="IActionBuildingContext"/>.
        /// </summary>
        protected void Bind <T>(IActionBuildingContext builder, string actionProperty, string actionEvent)
        {
            ValidateProperty(builder.ActionTarget, this.PropertyName, typeof(T));
            ValidateEvent(builder.ActionTarget, this.ChangeEventName);

            IObservablePropertyBinding <T> toolBinding   = new DynamicObservablePropertyBinding <T>(builder.ActionTarget, this.PropertyName, this.ChangeEventName);
            IObservablePropertyBinding <T> actionBinding = new DynamicObservablePropertyBinding <T>(builder.Action, actionProperty, actionEvent);

            ObservablePropertyCoupler <T> .Couple(toolBinding, actionBinding);
        }
Esempio n. 2
0
        /// <summary>
        /// Binds an <see cref="IAction"/> instance to the <paramref name="actionProperty"/> and
        /// <paramref name="actionEvent"/> on the target object, via the specified <see cref="IActionBuildingContext"/>.
        /// </summary>
        protected void Bind <T>(IActionBuildingContext builder, string actionProperty, string actionEvent)
        {
            ValidateProperty(builder.ActionTarget, this.PropertyName, typeof(T));

            // the change event could be null, in which case there is nothing to validate
            if (!string.IsNullOrEmpty(this.ChangeEventName))
            {
                ValidateEvent(builder.ActionTarget, this.ChangeEventName);
            }

            IObservablePropertyBinding <T> toolBinding   = new DynamicObservablePropertyBinding <T>(builder.ActionTarget, this.PropertyName, this.ChangeEventName);
            IObservablePropertyBinding <T> actionBinding = new DynamicObservablePropertyBinding <T>(builder.Action, actionProperty, actionEvent);

            ObservablePropertyCoupler <T> .Couple(toolBinding, actionBinding);
        }