/// <summary> /// Gets notified that the specified object has bound to a property of ours. /// </summary> /// <param name="boundObject">The instance that has bound the specified property.</param> /// <param name="binding"></param> internal void OnPropertyBoundExternally(PropertyBinding binding, RadObject boundObject) { RadPropertyValue propVal = this.propertyValues.GetEntry(binding.SourceProperty, true); //register the bound object and its property propVal.AddBoundObject(new PropertyBoundObject(boundObject, binding.BoundProperty)); }
internal void OnPropertyUnboundExternally(PropertyBinding binding, RadObject boundObject) { if (this.IsDisposing) { return; } RadPropertyValue entry = this.propertyValues.GetEntry(binding.SourceProperty, false); if (entry == null) { return; } entry.BeginUpdate(true, false); entry.RemoveBoundObject(boundObject); if ((binding.BindingOptions & PropertyBindingOptions.TwoWay) == PropertyBindingOptions.TwoWay) { int num1 = (int)this.ResetValueCore(entry, ValueResetFlags.TwoWayBindingLocal); } if ((binding.BindingOptions & PropertyBindingOptions.PreserveAsLocalValue) == PropertyBindingOptions.PreserveAsLocalValue) { entry.SetLocalValue(binding.GetValue()); } entry.EndUpdate(true, false); int num2 = (int)this.UpdateValueCore(entry); }
public ValueUpdateResult BindProperty( RadProperty propertyToBind, RadObject sourceObject, RadProperty sourceProperty, PropertyBindingOptions options) { if (sourceObject == null) { throw new ArgumentNullException("Binding source object"); } if (sourceObject.IsDisposing || sourceObject.IsDisposed) { return(ValueUpdateResult.NotUpdated); } RadPropertyValue entry = this.propertyValues.GetEntry(propertyToBind, true); if (entry.PropertyBinding != null) { entry.BeginUpdate(true, false); int num = (int)this.ResetValueCore(entry, ValueResetFlags.Binding); entry.EndUpdate(true, false); } PropertyBinding binding = new PropertyBinding(sourceObject, propertyToBind, sourceProperty, options); ValueUpdateResult valueUpdateResult = this.SetValueCore(entry, (object)binding, (object)null, ValueSource.PropertyBinding); if ((options & PropertyBindingOptions.NoChangeNotify) == (PropertyBindingOptions)0) { sourceObject.OnPropertyBoundExternally(binding, this); } return(valueUpdateResult); }
/// <summary> /// Gets notified that the specified object has unbound itself from a property of ours. /// </summary> /// <param name="boundObject"></param> /// <param name="binding"></param> internal void OnPropertyUnboundExternally(PropertyBinding binding, RadObject boundObject) { if (this.IsDisposing) { return; } RadPropertyValue propVal = this.propertyValues.GetEntry(binding.SourceProperty, false); if (propVal == null) { return; } propVal.BeginUpdate(true, false); //remove previously registered relations propVal.RemoveBoundObject(boundObject); if ((binding.BindingOptions & PropertyBindingOptions.TwoWay) == PropertyBindingOptions.TwoWay) { //reset the local value applied from the two-way binding this.ResetValueCore(propVal, ValueResetFlags.TwoWayBindingLocal); } if ((binding.BindingOptions & PropertyBindingOptions.PreserveAsLocalValue) == PropertyBindingOptions.PreserveAsLocalValue) { propVal.SetLocalValue(binding.GetValue()); } propVal.EndUpdate(true, false); this.UpdateValueCore(propVal); }
internal void Dispose() { ++this.lockComposeCount; ++this.lockValueUpdateCount; if (this.owner != null) { this.owner.RemoveBinding(this); } if (this.boundObjects != null) { for (int index = this.boundObjects.Count - 1; index >= 0; --index) { PropertyBoundObject boundObject = this.boundObjects[index]; RadObject radObject = boundObject.Object; if (radObject != null && !radObject.IsDisposed && !radObject.IsDisposing) { int num = (int)radObject.UnbindProperty(boundObject.Property); } } this.boundObjects.Clear(); } this.property = (RadProperty)null; this.metadata = (RadPropertyMetadata)null; this.owner = (RadObject)null; this.propertyBinding = (PropertyBinding)null; this.animationSetting = (AnimatedPropertySetting)null; this.styleSetting = (IPropertySetting)null; }
/// <summary> /// Notifies a binding source that a change occured in a two-way bound property. /// </summary> /// <param name="binding"></param> /// <param name="newValue"></param> internal void OnTwoWayBoundPropertyChanged(PropertyBinding binding, object newValue) { RadPropertyValue propVal = this.propertyValues.GetEntry(binding.SourceProperty, false); if (propVal != null) { this.SetValueCore(propVal, null, newValue, ValueSource.LocalFromBinding); } }
internal void SetBinding(PropertyBinding binding) { if (binding == null && this.propertyBinding != null && (this.propertyBinding.BindingOptions & PropertyBindingOptions.PreserveAsLocalValue) == PropertyBindingOptions.PreserveAsLocalValue) { this.localValue = this.propertyBinding.GetValue(); } this.propertyBinding = binding; this.valueSource = ValueSource.Unknown; }
internal void OnTwoWayBoundPropertyChanged(PropertyBinding binding, object newValue) { RadPropertyValue entry = this.propertyValues.GetEntry(binding.SourceProperty, false); if (entry == null) { return; } int num = (int)this.SetValueCore(entry, (object)null, newValue, ValueSource.LocalFromBinding); }
/// <summary> /// Applies the specified binding and forces current value re-evaluation. /// </summary> /// <param name="binding"></param> internal void SetBinding(PropertyBinding binding) { //check whether we need to remember the bindign value as local if (binding == null && this.propertyBinding != null) { if ((this.propertyBinding.BindingOptions & PropertyBindingOptions.PreserveAsLocalValue) == PropertyBindingOptions.PreserveAsLocalValue) { this.localValue = this.propertyBinding.GetValue(); } } this.propertyBinding = binding; this.valueSource = ValueSource.Unknown; }
internal void Copy(RadPropertyValue source) { this.valueSource = source.valueSource; this.localValue = source.localValue; this.localValueFromBinding = source.localValueFromBinding; this.defaultValueOverride = source.defaultValueOverride; this.currentValue = source.currentValue; this.iscurrentValueCoerced = source.iscurrentValueCoerced; this.isSetAtDesignTime = source.isSetAtDesignTime; this.animationSetting = source.animationSetting; this.styleSetting = source.styleSetting; this.propertyBinding = source.propertyBinding; this.animatedValue = source.animatedValue; }
/// <summary> /// Detaches binding reference from the binding source. /// </summary> /// <param name="propVal"></param> internal void RemoveBinding(RadPropertyValue propVal) { PropertyBinding binding = propVal.PropertyBinding; if (binding != null) { //we need to reset current binding (unregister from source object's bound objects list) RadObject bindingSource = binding.SourceObject; if (bindingSource != null && ((binding.BindingOptions & PropertyBindingOptions.NoChangeNotify) == 0)) { bindingSource.OnPropertyUnboundExternally(binding, this); } } }
internal void RemoveBinding(RadPropertyValue propVal) { PropertyBinding propertyBinding = propVal.PropertyBinding; if (propertyBinding == null) { return; } RadObject sourceObject = propertyBinding.SourceObject; if (sourceObject == null || (propertyBinding.BindingOptions & PropertyBindingOptions.NoChangeNotify) != (PropertyBindingOptions)0) { return; } sourceObject.OnPropertyUnboundExternally(propertyBinding, this); }
/// <summary> /// Binds the specified property to a property of the provided binding source object. /// </summary> /// <param name="propertyToBind">Our property that is about to be bound.</param> /// <param name="sourceObject">The object to which source property belongs.</param> /// <param name="sourceProperty">The property to which we will bind.</param> /// <param name="options">Additional options, specifying the binding operation.</param> public ValueUpdateResult BindProperty(RadProperty propertyToBind, RadObject sourceObject, RadProperty sourceProperty, PropertyBindingOptions options) { if (sourceObject == null) { throw new ArgumentNullException("Binding source object"); } if (sourceObject.IsDisposing || sourceObject.IsDisposed) { return(ValueUpdateResult.NotUpdated); //throw new ObjectDisposedException("Binding source object"); } RadPropertyValue propVal = this.propertyValues.GetEntry(propertyToBind, true); //remove previous binding (if any) if (propVal.PropertyBinding != null) { //lock subsequent value updates propVal.BeginUpdate(true, false); this.ResetValueCore(propVal, ValueResetFlags.Binding); propVal.EndUpdate(true, false); } //create a new binding PropertyBinding binding = new PropertyBinding(sourceObject, propertyToBind, sourceProperty, options); //apply binding ValueUpdateResult result = this.SetValueCore(propVal, binding, null, ValueSource.PropertyBinding); if ((options & PropertyBindingOptions.NoChangeNotify) == 0) { //register ourselves as bound for source's property sourceObject.OnPropertyBoundExternally(binding, this); } return(result); }
internal void OnPropertyBoundExternally(PropertyBinding binding, RadObject boundObject) { this.propertyValues.GetEntry(binding.SourceProperty, true).AddBoundObject(new PropertyBoundObject(boundObject, binding.BoundProperty)); }