ObservableObjectBaseSet Method

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: 7.0.0-rc.1
protected bool Set(
	Object? value,
	bool invokeChangedEvent = true,
	string propertyName = null


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

Return Value

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


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.


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.

See Also