ObservableObjectBaseSet Method

KGy SOFT Core Libraries Help
Sets the value of a property.
For an example, see the Remarks section of the ObservableObjectBase class.

Namespace:  KGySoft.ComponentModel
Assembly:  KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 5.3.0

protected bool Set(
	Object value,
	bool invokeChangedEvent = true,
	string propertyName = null


Type: SystemObject
The value to set.
invokeChangedEvent (Optional)
Type: SystemBoolean
If , and the value is different from the previously stored value, then invokes the PropertyChanged event.
propertyName (Optional)
Type: SystemString
Name of the property to set. This parameter is optional.
Default value: The name of the caller member.

Return Value

Type: Boolean
 if property has been set (change occurred); otherwise, .

ArgumentNullExceptionpropertyName is .
InvalidOperationExceptionpropertyName cannot be set.
CanSetProperty is not overridden and propertyName is not an actual instance property in this instance, or value is not compatible with the property type.

If a property is redefined in a derived class with a different type, or a type has multiple indexers with different types, the this method may throw an InvalidOperationException. Overriding the CanSetProperty method can solve this issue but it may lead to further errors if multiple properties use the same key in the inner storage.

See Also