Skip to main content

AvaloniaProperty Class

Definition

Namespace:Avalonia
Assembly:Avalonia.Base
Package:Avalonia

Base class for avalonia properties.

public class AvaloniaProperty

Inheritance: object -> AvaloniaProperty

Implements: IPropertyInfo, IEquatable<AvaloniaProperty>

Methods

NameDescription
BindReturns a binding accessor that can be passed to Avalonia.AvaloniaObject's [] operator to initiate a binding.
Equals (2 overloads)No summary available.
GetHashCodeNo summary available.
GetMetadata (3 overloads)No summary available.
IsValidValueChecks whether the value is valid for the property.
RegisterNo summary available.
RegisterAttached (2 overloads)No summary available.
RegisterDirectNo summary available.
ToStringGets the string representation of the property.
UnregisterNo summary available.

Bind Method

Returns a binding accessor that can be passed to Avalonia.AvaloniaObject's [] operator to initiate a binding.

public Avalonia.Data.IndexerDescriptor Bind()

Returns

Avalonia.Data.IndexerDescriptor

A Avalonia.Data.IndexerDescriptor.

Remarks

The ! and ~ operators are short forms of this.

Equals overloads

Equals Method

public bool Equals(Avalonia.AvaloniaProperty other)
Parameters

other Avalonia.AvaloniaProperty

Returns

bool

Equals Method

public bool Equals(object obj)
Parameters

obj object

Returns

bool

GetHashCode Method

public int GetHashCode()

Returns

int

GetMetadata overloads

GetMetadata Method

public Avalonia.AvaloniaPropertyMetadata GetMetadata<T>()
Type Parameters

T

Returns

Avalonia.AvaloniaPropertyMetadata

GetMetadata Method

Gets the Avalonia.AvaloniaPropertyMetadata which applies to this property when it is used with the specified object.

public Avalonia.AvaloniaPropertyMetadata GetMetadata(Avalonia.AvaloniaObject owner)
Parameters

owner Avalonia.AvaloniaObject

The object for which to retrieve metadata.

Returns

Avalonia.AvaloniaPropertyMetadata

GetMetadata Method

public Avalonia.AvaloniaPropertyMetadata GetMetadata(Type type)
Parameters

type Type

The type for which to retrieve metadata.

Returns

Avalonia.AvaloniaPropertyMetadata

Remarks

For performance, prefer the Avalonia.AvaloniaProperty.GetMetadata(Avalonia.AvaloniaObject) overload when possible.

IsValidValue Method

Checks whether the value is valid for the property.

public bool IsValidValue(object value)

Parameters

value object

The value.

Returns

bool

True if the value is valid, otherwise false.

Register Method

public Avalonia.StyledProperty<TValue><TValue> Register<TOwner, TValue>(string name, TValue defaultValue, bool inherits, Avalonia.Data.BindingMode defaultBindingMode, Func<TValue, bool> validate, Func<Avalonia.AvaloniaObject, TValue, TValue> coerce, bool enableDataValidation)

Parameters

name string

defaultValue TValue

inherits bool

defaultBindingMode Avalonia.Data.BindingMode

validate Func<TValue, bool>

coerce Func<Avalonia.AvaloniaObject, TValue, TValue>

enableDataValidation bool

Type Parameters

TOwner

TValue

Returns

Avalonia.StyledProperty<TValue><TValue>

RegisterAttached overloads

RegisterAttached Method

public Avalonia.AttachedProperty<TValue><TValue> RegisterAttached<THost, TValue>(string name, Type ownerType, TValue defaultValue, bool inherits, Avalonia.Data.BindingMode defaultBindingMode, Func<TValue, bool> validate, Func<Avalonia.AvaloniaObject, TValue, TValue> coerce)
Parameters

name string

ownerType Type

defaultValue TValue

inherits bool

defaultBindingMode Avalonia.Data.BindingMode

validate Func<TValue, bool>

coerce Func<Avalonia.AvaloniaObject, TValue, TValue>

Type Parameters

THost

TValue

Returns

Avalonia.AttachedProperty<TValue><TValue>

RegisterAttached Method

public Avalonia.AttachedProperty<TValue><TValue> RegisterAttached<TOwner, THost, TValue>(string name, TValue defaultValue, bool inherits, Avalonia.Data.BindingMode defaultBindingMode, Func<TValue, bool> validate, Func<Avalonia.AvaloniaObject, TValue, TValue> coerce)
Parameters

name string

defaultValue TValue

inherits bool

defaultBindingMode Avalonia.Data.BindingMode

validate Func<TValue, bool>

coerce Func<Avalonia.AvaloniaObject, TValue, TValue>

Type Parameters

TOwner

THost

TValue

Returns

Avalonia.AttachedProperty<TValue><TValue>

RegisterDirect Method

public Avalonia.DirectProperty<TOwner,TValue><TOwner, TValue> RegisterDirect<TOwner, TValue>(string name, Func<TOwner, TValue> getter, Action<TOwner, TValue> setter, TValue unsetValue, Avalonia.Data.BindingMode defaultBindingMode, bool enableDataValidation)

Parameters

name string

getter Func<TOwner, TValue>

setter Action<TOwner, TValue>

unsetValue TValue

defaultBindingMode Avalonia.Data.BindingMode

enableDataValidation bool

Type Parameters

TOwner

TValue

Returns

Avalonia.DirectProperty<TOwner,TValue><TOwner, TValue>

ToString Method

Gets the string representation of the property.

public string ToString()

Returns

string

The property's string representation.

Unregister Method

public void Unregister(Type type)

Parameters

type Type

Properties

NameDescription
ChangedGets an observable that is fired when this property changes on any Avalonia.AvaloniaObject instance.
InheritsGets a value indicating whether the property inherits its value.
IsAttachedGets a value indicating whether this is an attached property.
IsDirectGets a value indicating whether this is a direct property.
IsReadOnlyGets a value indicating whether this is a readonly property.
NameGets the name of the property.
OwnerTypeGets the type of the class that registered the property.
PropertyTypeGets the type of the property's value.

Changed Property

Gets an observable that is fired when this property changes on any Avalonia.AvaloniaObject instance.

public IObservable<Avalonia.AvaloniaPropertyChangedEventArgs> Changed { get; set; }

Value

An observable that is fired when this property changes on any Avalonia.AvaloniaObject instance.

Inherits Property

Gets a value indicating whether the property inherits its value.

public bool Inherits { get; set; }

IsAttached Property

Gets a value indicating whether this is an attached property.

public bool IsAttached { get; set; }

IsDirect Property

Gets a value indicating whether this is a direct property.

public bool IsDirect { get; set; }

IsReadOnly Property

Gets a value indicating whether this is a readonly property.

public bool IsReadOnly { get; set; }

Name Property

Gets the name of the property.

public string Name { get; set; }

OwnerType Property

Gets the type of the class that registered the property.

public Type OwnerType { get; set; }

PropertyType Property

Gets the type of the property's value.

public Type PropertyType { get; set; }

Fields

NameDescription
UnsetValueRepresents an unset property value.

UnsetValue Field

Represents an unset property value.

public object UnsetValue