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