Skip to main content

RegisterDirect<TOwner, TValue> Method

Registers a direct AvaloniaProperty.

Definition​

Namespace: Avalonia
Assembly: Avalonia.Base (in Avalonia.Base.dll)

public static DirectProperty<TOwner, TValue> RegisterDirect<TOwner, TValue>(
string name,
Func<TOwner, TValue> getter,
Action<TOwner, TValue>? setter = null,
TValue unsetValue = null,
BindingMode defaultBindingMode = BindingMode.OneWay,
bool enableDataValidation = false
)
where TOwner : AvaloniaObject

Parameters​

  String
The name of the property.
  Func(TOwner, TValue)
Gets the current value of the property.
  Action(TOwner, TValue)  (Optional)
Sets the value of the property.
  TValue  (Optional)
The value to use when the property is cleared. ⚠️ Be careful with reference types: if you pass a mutable object (like a list), it will be shared across all instances using this property. Use value types or immutable objects.
  BindingMode  (Optional)
The default binding mode for the property.
  Boolean  (Optional)
Whether the property is interested in data validation.

Type Parameters​

The type of the class that is registering the property.
The type of the property's value.

Return Value​

DirectProperty(TOwner, TValue)
A AvaloniaProperty(TValue)

See Also​

Reference​

AvaloniaProperty Class
Avalonia Namespace