Skip to main content

AvaloniaObject Class

Definition​

Namespace:Avalonia
Assembly:Avalonia.Base
Package:Avalonia

An object with Avalonia.AvaloniaProperty support.

public class AvaloniaObject

Remarks​

This class is analogous to DependencyObject in WPF.

Constructors​

NameDescription
AvaloniaObjectInitializes a new instance of the Avalonia.AvaloniaObject class.

AvaloniaObject Constructor​

Initializes a new instance of the Avalonia.AvaloniaObject class.

public AvaloniaObject()

Methods​

NameDescription
Bind (8 overloads)Binds a Avalonia.AvaloniaProperty to an Avalonia.Data.BindingBase.
CheckAccessReturns a value indicating whether the current thread is the UI thread.
ClearValue (4 overloads)Clears a Avalonia.AvaloniaProperty's local value.
CoerceValueCoerces the specified Avalonia.AvaloniaProperty.
EqualsCompares two objects using reference equality.
GetBaseValueNo summary available.
GetHashCodeGets the hash code for the object.
GetValue (3 overloads)Gets a Avalonia.AvaloniaProperty value.
IsAnimatingChecks whether a Avalonia.AvaloniaProperty is animating.
IsSetChecks whether a Avalonia.AvaloniaProperty is set on this object.
SetCurrentValue (2 overloads)Sets the value of a dependency property without changing its value source.
SetValue (3 overloads)Sets a Avalonia.AvaloniaProperty value.
VerifyAccessChecks that the current thread is the UI thread and throws if not.

Bind overloads​

Bind Method​

Binds a Avalonia.AvaloniaProperty to an Avalonia.Data.BindingBase.

public Avalonia.Data.BindingExpressionBase Bind(Avalonia.AvaloniaProperty property, Avalonia.Data.BindingBase binding)
Parameters​

property Avalonia.AvaloniaProperty

The property.

binding Avalonia.Data.BindingBase

The binding.

Returns​

Avalonia.Data.BindingExpressionBase

The binding expression which represents the binding instance on this object.

Bind Method​

public IDisposable Bind(Avalonia.AvaloniaProperty property, IObservable<object> source, Avalonia.Data.BindingPriority priority)
Parameters​

property Avalonia.AvaloniaProperty

source IObservable<object>

priority Avalonia.Data.BindingPriority

Returns​

IDisposable

Bind Method​

public IDisposable Bind<T>(Avalonia.DirectPropertyBase<TValue><T> property, IObservable<Avalonia.Data.BindingValue<T><T>> source)
Parameters​

property Avalonia.DirectPropertyBase<TValue><T>

source IObservable<Avalonia.Data.BindingValue<T><T>>

Type Parameters​

T

Returns​

IDisposable

Bind Method​

public IDisposable Bind<T>(Avalonia.DirectPropertyBase<TValue><T> property, IObservable<object> source)
Parameters​

property Avalonia.DirectPropertyBase<TValue><T>

source IObservable<object>

Type Parameters​

T

Returns​

IDisposable

Bind Method​

public IDisposable Bind<T>(Avalonia.DirectPropertyBase<TValue><T> property, IObservable<T> source)
Parameters​

property Avalonia.DirectPropertyBase<TValue><T>

source IObservable<T>

Type Parameters​

T

Returns​

IDisposable

Bind Method​

public IDisposable Bind<T>(Avalonia.StyledProperty<TValue><T> property, IObservable<Avalonia.Data.BindingValue<T><T>> source, Avalonia.Data.BindingPriority priority)
Parameters​

property Avalonia.StyledProperty<TValue><T>

source IObservable<Avalonia.Data.BindingValue<T><T>>

priority Avalonia.Data.BindingPriority

Type Parameters​

T

Returns​

IDisposable

Bind Method​

public IDisposable Bind<T>(Avalonia.StyledProperty<TValue><T> property, IObservable<object> source, Avalonia.Data.BindingPriority priority)
Parameters​

property Avalonia.StyledProperty<TValue><T>

source IObservable<object>

priority Avalonia.Data.BindingPriority

Type Parameters​

T

Returns​

IDisposable

Bind Method​

public IDisposable Bind<T>(Avalonia.StyledProperty<TValue><T> property, IObservable<T> source, Avalonia.Data.BindingPriority priority)
Parameters​

property Avalonia.StyledProperty<TValue><T>

source IObservable<T>

priority Avalonia.Data.BindingPriority

Type Parameters​

T

Returns​

IDisposable

CheckAccess Method​

Returns a value indicating whether the current thread is the UI thread.

public bool CheckAccess()

Returns​

bool

true if the current thread is the UI thread; otherwise false.

ClearValue overloads​

ClearValue Method​

Clears a Avalonia.AvaloniaProperty's local value.

public void ClearValue(Avalonia.AvaloniaProperty property)
Parameters​

property Avalonia.AvaloniaProperty

The property.

ClearValue Method​

public void ClearValue<T>(Avalonia.AvaloniaProperty<TValue><T> property)
Parameters​

property Avalonia.AvaloniaProperty<TValue><T>

Type Parameters​

T

ClearValue Method​

public void ClearValue<T>(Avalonia.DirectPropertyBase<TValue><T> property)
Parameters​

property Avalonia.DirectPropertyBase<TValue><T>

Type Parameters​

T

ClearValue Method​

public void ClearValue<T>(Avalonia.StyledProperty<TValue><T> property)
Parameters​

property Avalonia.StyledProperty<TValue><T>

Type Parameters​

T

CoerceValue Method​

Coerces the specified Avalonia.AvaloniaProperty.

public void CoerceValue(Avalonia.AvaloniaProperty property)

Parameters​

property Avalonia.AvaloniaProperty

The property.

Equals Method​

Compares two objects using reference equality.

public bool Equals(object obj)

Parameters​

obj object

The object to compare.

Returns​

bool

Remarks​

Overriding Equals and GetHashCode on an AvaloniaObject is disallowed for two reasons:

  • AvaloniaObjects are by their nature mutable
  • The presence of attached properties means that the semantics of equality are difficult to define

See https://github.com/AvaloniaUI/Avalonia/pull/2747 for the discussion that prompted this.

GetBaseValue Method​

public Avalonia.Data.Optional<T><T> GetBaseValue<T>(Avalonia.StyledProperty<TValue><T> property)

Parameters​

property Avalonia.StyledProperty<TValue><T>

Type Parameters​

T

Returns​

Avalonia.Data.Optional<T><T>

GetHashCode Method​

Gets the hash code for the object.

public int GetHashCode()

Returns​

int

Remarks​

Overriding Equals and GetHashCode on an AvaloniaObject is disallowed for two reasons:

  • AvaloniaObjects are by their nature mutable
  • The presence of attached properties means that the semantics of equality are difficult to define

See https://github.com/AvaloniaUI/Avalonia/pull/2747 for the discussion that prompted this.

GetValue overloads​

GetValue Method​

Gets a Avalonia.AvaloniaProperty value.

public object GetValue(Avalonia.AvaloniaProperty property)
Parameters​

property Avalonia.AvaloniaProperty

The property.

Returns​

object

The value.

GetValue Method​

public T GetValue<T>(Avalonia.DirectPropertyBase<TValue><T> property)
Parameters​

property Avalonia.DirectPropertyBase<TValue><T>

Type Parameters​

T

Returns​

T

GetValue Method​

public T GetValue<T>(Avalonia.StyledProperty<TValue><T> property)
Parameters​

property Avalonia.StyledProperty<TValue><T>

Type Parameters​

T

Returns​

T

IsAnimating Method​

Checks whether a Avalonia.AvaloniaProperty is animating.

public bool IsAnimating(Avalonia.AvaloniaProperty property)

Parameters​

property Avalonia.AvaloniaProperty

The property.

Returns​

bool

True if the property is animating, otherwise false.

IsSet Method​

Checks whether a Avalonia.AvaloniaProperty is set on this object.

public bool IsSet(Avalonia.AvaloniaProperty property)

Parameters​

property Avalonia.AvaloniaProperty

The property.

Returns​

bool

True if the property is set, otherwise false.

Remarks​

Returns true if property is a styled property which has a value assigned to it or a binding targeting it; otherwise false.

SetCurrentValue overloads​

SetCurrentValue Method​

Sets the value of a dependency property without changing its value source.

public void SetCurrentValue(Avalonia.AvaloniaProperty property, object value)
Parameters​

property Avalonia.AvaloniaProperty

The property.

value object

The value.

Remarks​

This method is used by a component that programmatically sets the value of one of its own properties without disabling an application's declared use of the property. The method changes the effective value of the property, but existing data bindings and styles will continue to work.

The new value will have the property's current Avalonia.Data.BindingPriority, even if that priority is Avalonia.Data.BindingPriority.Unset or Avalonia.Data.BindingPriority.Inherited.

SetCurrentValue Method​

public void SetCurrentValue<T>(Avalonia.StyledProperty<TValue><T> property, T value)
Parameters​

property Avalonia.StyledProperty<TValue><T>

value T

Type Parameters​

T

SetValue overloads​

SetValue Method​

Sets a Avalonia.AvaloniaProperty value.

public IDisposable SetValue(Avalonia.AvaloniaProperty property, object value, Avalonia.Data.BindingPriority priority)
Parameters​

property Avalonia.AvaloniaProperty

The property.

value object

The value.

priority Avalonia.Data.BindingPriority

The priority of the value.

Returns​

IDisposable

SetValue Method​

public void SetValue<T>(Avalonia.DirectPropertyBase<TValue><T> property, T value)
Parameters​

property Avalonia.DirectPropertyBase<TValue><T>

value T

Type Parameters​

T

SetValue Method​

public IDisposable SetValue<T>(Avalonia.StyledProperty<TValue><T> property, T value, Avalonia.Data.BindingPriority priority)
Parameters​

property Avalonia.StyledProperty<TValue><T>

value T

priority Avalonia.Data.BindingPriority

Type Parameters​

T

Returns​

IDisposable

VerifyAccess Method​

Checks that the current thread is the UI thread and throws if not.

public void VerifyAccess()

Properties​

NameDescription
DispatcherReturns the Avalonia.AvaloniaObject.Dispatcher that this Avalonia.AvaloniaObject is associated with.
ItemNo summary available.

Dispatcher Property​

Returns the Avalonia.AvaloniaObject.Dispatcher that this Avalonia.AvaloniaObject is associated with.

public Avalonia.Threading.Dispatcher Dispatcher { get; set; }

Item Property​

public Avalonia.Data.BindingBase Item { get; set; }

Events​

NameDescription
PropertyChangedRaised when a Avalonia.AvaloniaProperty value changes on this object.

PropertyChanged Event​

Raised when a Avalonia.AvaloniaProperty value changes on this object.

public event EventHandler<Avalonia.AvaloniaPropertyChangedEventArgs> PropertyChanged