Table of Contents

Class DirectProperty<TOwner, TValue>

Namespace
Avalonia
Assembly
Avalonia.Base.dll

A direct avalonia property.

public class DirectProperty<TOwner, TValue> : DirectPropertyBase<TValue>, IEquatable<AvaloniaProperty>, IPropertyInfo where TOwner : AvaloniaObject

Type Parameters

TOwner

The class that registered the property.

TValue

The type of the property's value.

Inheritance
DirectProperty<TOwner, TValue>
Implements
Inherited Members

Remarks

Direct avalonia properties are backed by a field on the object, but exposed via the AvaloniaProperty system. They hold a getter and an optional setter which allows the avalonia property system to read and write the current value.

Properties

Getter

Gets the getter function.

public Func<TOwner, TValue> Getter { get; }

Property Value

Func<TOwner, TValue>

Setter

Gets the setter function.

public Action<TOwner, TValue>? Setter { get; }

Property Value

Action<TOwner, TValue>

Methods

AddOwner<TNewOwner>(Func<TNewOwner, TValue>, Action<TNewOwner, TValue>?, TValue, BindingMode, bool)

Registers the direct property on another type.

public DirectProperty<TNewOwner, TValue> AddOwner<TNewOwner>(Func<TNewOwner, TValue> getter, Action<TNewOwner, TValue>? setter = null, TValue unsetValue = default, BindingMode defaultBindingMode = BindingMode.Default, bool enableDataValidation = false) where TNewOwner : AvaloniaObject

Parameters

getter Func<TNewOwner, TValue>

Gets the current value of the property.

setter Action<TNewOwner, TValue>

Sets the value of the property.

unsetValue TValue

The value to use when the property is set to UnsetValue

defaultBindingMode BindingMode

The default binding mode for the property.

enableDataValidation bool

Whether the property is interested in data validation.

Returns

DirectProperty<TNewOwner, TValue>

The property.

Type Parameters

TNewOwner

The type of the additional owner.