Class AttachedProperties
Provides per-instance storage for attached property values, keyed by the owning object's lifetime.
public static class AttachedProperties
- Inheritance
-
AttachedProperties
- Inherited Members
Remarks
Static getter/setter accessors declared for an AttachedPropertyAttribute-marked
type (e.g. Grid.GetRow/Grid.SetRow) should read and write through this store rather than
maintaining their own storage, so values live and die with the target instance.
Methods
GetValue<T>(object, string, T)
Gets the attached value stored for target under key.
public static T GetValue<T>(object target, string key, T defaultValue = default)
Parameters
targetobjectThe object the value is attached to.
keystringThe name that identifies the attached property.
defaultValueTThe value returned when nothing has been stored yet.
Returns
- T
The stored value, or
defaultValueif none was set.
Type Parameters
TThe type of the stored value.
SetValue<T>(object, string, T)
Sets the attached value stored for target under key.
public static void SetValue<T>(object target, string key, T value)
Parameters
targetobjectThe object the value is attached to.
keystringThe name that identifies the attached property.
valueTThe value to store.
Type Parameters
TThe type of the value to store.