/// <internalonly /> protected override void Activate() { if (_valueBinding == null) { throw new InvalidOperationException("The ValueBinding property on BoundParameter must be set."); } _binder = new BindingShim(AssociatedElement, _valueBinding, OnValueBindingChanged); }
/// <internalonly /> protected override void InvokeAction(EventArgs e) { if (String.IsNullOrEmpty(_propertyName)) { throw new InvalidOperationException("The PropertyName property must be set on a SetProperty action."); } if (_valueBinding == null) { throw new InvalidOperationException("The ValueBinding property must be set on a SetProperty action."); } object target = GetTarget(); if (target == null) { throw new InvalidOperationException("There is no target object to set the specified property '" + _propertyName + "'."); } PropertyInfo targetProperty = target.GetType().GetProperty(_propertyName); if (targetProperty == null) { throw new InvalidOperationException("The specified property '" + _propertyName + "' was not found on an object of type '" + target.GetType().FullName + "'"); } if (_binder == null) { _binder = new BindingShim(AssociatedObject, _valueBinding, null); } object value = _binder.Value; if (targetProperty.PropertyType != typeof(Object)) { value = Convert.ChangeType(value, targetProperty.PropertyType, CultureInfo.CurrentCulture); } targetProperty.SetValue(target, value, null); }
/// <internalonly /> protected override void OnDetach() { if (_binder != null) { _binder.Dispose(); _binder = null; } base.OnDetach(); }
/// <internalonly /> protected override void Deactivate() { _binder.Dispose(); _binder = null; }