/// <summary> /// Sets the value of a dependency property. /// </summary> /// <param name="property">The dependency property whose value is to be set.</param> /// <param name="value">The value to set.</param> /// <exception cref="System.ArgumentException">Value is of wrong type for this DependencyProperty.</exception> public void SetValue(DependencyProperty property, object value) { if (!property.IsValidType(value)) { throw new ArgumentException("Value is of wrong type for this DependencyProperty."); } if (property.PropertyType.IsValueType) { SetValueType(property, value); } else { SetValueWeakRef(property, value); } }
public void SetValue(DependencyProperty dp, object value) { if (IsSealed) { throw new InvalidOperationException("Cannot manipulate property values on a sealed DependencyObject"); } if (!dp.IsValidType(value)) { throw new ArgumentException("value not of the correct type for this DependencyProperty"); } ValidateValueCallback validate = dp.ValidateValueCallback; if (validate != null && !validate(value)) { throw new Exception("Value does not validate"); } else { properties[dp] = value; } }
public void SetValue(DependencyProperty dp, object value) { if (IsSealed) throw new InvalidOperationException ("Cannot manipulate property values on a sealed DependencyObject"); if (!dp.IsValidType (value)) throw new ArgumentException ("value not of the correct type for this DependencyProperty"); ValidateValueCallback validate = dp.ValidateValueCallback; if (validate != null && !validate(value)) throw new Exception("Value does not validate"); else properties[dp] = value; }
/// <summary> /// Sets the value of a dependency property. /// </summary> /// <param name="property">The dependency property whose value is to be set.</param> /// <param name="value">The value to set.</param> /// <exception cref="System.ArgumentException">Value is of wrong type for this DependencyProperty.</exception> public void SetValue(DependencyProperty property, object value) { if (!property.IsValidType(value)) throw new ArgumentException("Value is of wrong type for this DependencyProperty."); if (property.PropertyType.IsValueType) SetValueType(property, value); else SetValueWeakRef(property, value); }