Skip to main content

GeneratedAttachedPropertyAttribute Class

Definition​

Namespace:Avalonia
Assembly:Avalonia.Base
Package:Avalonia

Instructs the Avalonia property source generator to emit an Avalonia.AttachedProperty<T> registration and accessor methods for the annotated partial Get method.

public class GeneratedAttachedPropertyAttribute

Inheritance: Attribute -> GeneratedAttachedPropertyAttribute

Remarks​

Apply to a static partial T Get{Name}(THost element) method declared on a partial class.

Constructors​

NameDescription
GeneratedAttachedPropertyAttributeNo summary available.

GeneratedAttachedPropertyAttribute Constructor​

public GeneratedAttachedPropertyAttribute()

Properties​

NameDescription
AddOwnerFromRe-owns an existing attached property from the specified base type instead of registering a new property. The source property must be a static {Name}Property member of the given type. Metadata may still be overridden with Avalonia.GeneratedAttachedPropertyAttribute.DefaultValue, Avalonia.GeneratedAttachedPropertyAttribute.DefaultBindingMode and Avalonia.GeneratedAttachedPropertyAttribute.CoerceMethodName.
CoerceMethodNameThe name of the coercion method, with signature static T {Method}(AvaloniaObject sender, T value). Declare it as an private static method on the same type.
DefaultBindingModeThe default binding mode for the property.
DefaultValueThe default value of the property. Must be a compile-time constant. For non-constant defaults, call {Name}Property.OverrideDefaultValue(...) in a static constructor instead.
InheritsWhether the property inherits its value down the logical tree.
ValidateMethodNameThe name of the validation method, with signature static bool {Method}(T value). Pass via nameof(...). Declare it as an private static method on the same type.

AddOwnerFrom Property​

Re-owns an existing attached property from the specified base type instead of registering a new property. The source property must be a static {Name}Property member of the given type. Metadata may still be overridden with Avalonia.GeneratedAttachedPropertyAttribute.DefaultValue, Avalonia.GeneratedAttachedPropertyAttribute.DefaultBindingMode and Avalonia.GeneratedAttachedPropertyAttribute.CoerceMethodName.

public Type AddOwnerFrom { get; set; }

CoerceMethodName Property​

The name of the coercion method, with signature static T {Method}(AvaloniaObject sender, T value). Declare it as an private static method on the same type.

public string CoerceMethodName { get; set; }

DefaultBindingMode Property​

The default binding mode for the property.

public Avalonia.Data.BindingMode DefaultBindingMode { get; set; }

DefaultValue Property​

The default value of the property. Must be a compile-time constant. For non-constant defaults, call {Name}Property.OverrideDefaultValue(...) in a static constructor instead.

public object DefaultValue { get; set; }

Inherits Property​

Whether the property inherits its value down the logical tree.

public bool Inherits { get; set; }

Remarks​

Cannot be used with Avalonia.GeneratedAttachedPropertyAttribute.AddOwnerFrom.

ValidateMethodName Property​

The name of the validation method, with signature static bool {Method}(T value). Pass via nameof(...). Declare it as an private static method on the same type.

public string ValidateMethodName { get; set; }

Remarks​

Cannot be used with Avalonia.GeneratedAttachedPropertyAttribute.AddOwnerFrom.