Skip to main content

GeneratedStyledPropertyAttribute Class

Definition​

Namespace:Avalonia
Assembly:Avalonia.Base
Package:Avalonia

Instructs the Avalonia property source generator to emit a Avalonia.StyledProperty<T> registration and accessor bodies for the annotated partial property.

public class GeneratedStyledPropertyAttribute

Inheritance: Attribute -> GeneratedStyledPropertyAttribute

Remarks​

Apply to a partial instance property with both get and set accessors, declared on a partial class deriving from Avalonia.AvaloniaObject.

Constructors​

NameDescription
GeneratedStyledPropertyAttributeNo summary available.

GeneratedStyledPropertyAttribute Constructor​

public GeneratedStyledPropertyAttribute()

Properties​

NameDescription
AddOwnerFromRe-owns an existing styled 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.GeneratedStyledPropertyAttribute.DefaultValue, Avalonia.GeneratedStyledPropertyAttribute.DefaultBindingMode and Avalonia.GeneratedStyledPropertyAttribute.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.
EnableDataValidationWhether the property is interested in data validation.
InheritsWhether the property inherits its value down the logical tree.
ValidateMethodNameThe name of the validation method, with signature static bool {Method}(T value). Declare it as an private static method on the same type.

AddOwnerFrom Property​

Re-owns an existing styled 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.GeneratedStyledPropertyAttribute.DefaultValue, Avalonia.GeneratedStyledPropertyAttribute.DefaultBindingMode and Avalonia.GeneratedStyledPropertyAttribute.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; }

EnableDataValidation Property​

Whether the property is interested in data validation.

public bool EnableDataValidation { 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.GeneratedStyledPropertyAttribute.AddOwnerFrom.

ValidateMethodName Property​

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

public string ValidateMethodName { get; set; }

Remarks​

Cannot be used with Avalonia.GeneratedStyledPropertyAttribute.AddOwnerFrom.