Click or drag to resize

PropertyStoreSetT Method (Object, T, PropertyChangedEventHandler, T, String)

Set the value for the specified property key, raising the propertyChanged handler if it has changed.

Namespace:  Eto
Assembly:  Eto (in Eto.dll) Version: 2.5.3-dev
Syntax
public bool Set<T>(
	Object key,
	T value,
	PropertyChangedEventHandler propertyChanged,
	T defaultValue = null,
	string propertyName = null
)

Parameters

key
Type: SystemObject
Key of the property to set.
value
Type: T
Value for the property.
propertyChanged
Type: System.ComponentModelPropertyChangedEventHandler
Property changed event handler to raise if the property value has changed.
defaultValue (Optional)
Type: T
Default value of the property to compare when removing the key
propertyName (Optional)
Type: SystemString
Name of the property, or omit to get the property name from the caller.

Type Parameters

T
The type of the property to set.

Return Value

Type: Boolean
true if the property was changed, false if not
Remarks
This is useful when creating properties that need to trigger changed events without having to write boilerplate code.
Examples
public class MyForm : Form, INotifyPropertyChanged
{
    static readonly MyPropertyKey = new object();

    public bool MyProperty
    {
        get { return Properties.Get<bool>(MyPropertyKey); }
        set { Properties.Set(MyPropertyKey, value, PropertyChanged); }
    }

    public event PropertyChangedEventHandler PropertyChanged;
}
See Also