Skip to main content

BindingNotification Class

Definition​

Namespace:Avalonia.Data
Assembly:Avalonia.Base
Package:Avalonia

Represents a binding notification that can be a valid binding value, or a binding or data validation error.

public class BindingNotification

Inheritance: object -> BindingNotification

Remarks​

This class is very similar to Avalonia.Data.BindingValue<T>, but where Avalonia.Data.BindingValue<T> is used by typed bindings, this class is used to hold binding and data validation errors in untyped bindings. As Avalonia moves towards using typed bindings by default we may want to remove this class.

Constructors​

NameDescription
BindingNotification (3 overloads)Initializes a new instance of the Avalonia.Data.BindingNotification class.

BindingNotification overloads​

BindingNotification Constructor​

Initializes a new instance of the Avalonia.Data.BindingNotification class.

public BindingNotification(Exception error, Avalonia.Data.BindingErrorType errorType)
Parameters​

error Exception

The binding error.

errorType Avalonia.Data.BindingErrorType

The type of the binding error.

BindingNotification Constructor​

Initializes a new instance of the Avalonia.Data.BindingNotification class.

public BindingNotification(Exception error, Avalonia.Data.BindingErrorType errorType, object fallbackValue)
Parameters​

error Exception

The binding error.

errorType Avalonia.Data.BindingErrorType

The type of the binding error.

fallbackValue object

The fallback value.

BindingNotification Constructor​

Initializes a new instance of the Avalonia.Data.BindingNotification class.

public BindingNotification(object value)
Parameters​

value object

The binding value.

Methods​

NameDescription
AddErrorAdds an error to the Avalonia.Data.BindingNotification.
ClearValueRemoves the Avalonia.Data.BindingNotification.Value and makes Avalonia.Data.BindingNotification.HasValue return null.
Equals (2 overloads)Compares a value to an instance of Avalonia.Data.BindingNotification for equality.
ExtractErrorGets an exception from an object that may be a Avalonia.Data.BindingNotification.
ExtractValueGets a value from an object that may be a Avalonia.Data.BindingNotification.
GetHashCodeGets the hash code for this instance of Avalonia.Data.BindingNotification.
SetValueSets the Avalonia.Data.BindingNotification.Value.
ToStringNo summary available.
UpdateValueUpdates the value of an object that may be a Avalonia.Data.BindingNotification.

AddError Method​

Adds an error to the Avalonia.Data.BindingNotification.

public void AddError(Exception e, Avalonia.Data.BindingErrorType type)

Parameters​

e Exception

The error to add.

type Avalonia.Data.BindingErrorType

The error type.

ClearValue Method​

Removes the Avalonia.Data.BindingNotification.Value and makes Avalonia.Data.BindingNotification.HasValue return null.

public void ClearValue()

Equals overloads​

Equals Method​

Compares a value to an instance of Avalonia.Data.BindingNotification for equality.

public bool Equals(Avalonia.Data.BindingNotification other)
Parameters​

other Avalonia.Data.BindingNotification

The value to compare.

Returns​

bool

true if the two instances are equal; otherwise false.

Equals Method​

Compares an object to an instance of Avalonia.Data.BindingNotification for equality.

public bool Equals(object obj)
Parameters​

obj object

The object to compare.

Returns​

bool

true if the two instances are equal; otherwise false.

ExtractError Method​

Gets an exception from an object that may be a Avalonia.Data.BindingNotification.

public object ExtractError(object o)

Parameters​

o object

The object.

Returns​

object

The value.

Remarks​

If o is a Avalonia.Data.BindingNotification then returns the binding notification's Avalonia.Data.BindingNotification.Error. If not, returns the object unchanged.

ExtractValue Method​

Gets a value from an object that may be a Avalonia.Data.BindingNotification.

public object ExtractValue(object o)

Parameters​

o object

The object.

Returns​

object

The value.

Remarks​

If o is a Avalonia.Data.BindingNotification then returns the binding notification's Avalonia.Data.BindingNotification.Value. If not, returns the object unchanged.

GetHashCode Method​

Gets the hash code for this instance of Avalonia.Data.BindingNotification.

public int GetHashCode()

Returns​

int

A hash code.

SetValue Method​

Sets the Avalonia.Data.BindingNotification.Value.

public void SetValue(object value)

Parameters​

value object

ToString Method​

public string ToString()

Returns​

string

UpdateValue Method​

Updates the value of an object that may be a Avalonia.Data.BindingNotification.

public object UpdateValue(object o, object value)

Parameters​

o object

The object that may be a binding notification.

value object

The new value.

Returns​

object

The updated binding notification if o is a binding notification; otherwise value.

Remarks​

If o is a Avalonia.Data.BindingNotification then sets its value to value. If value is a Avalonia.Data.BindingNotification then the value will first be extracted.

Properties​

NameDescription
ErrorGets the error that occurred on the source, if any.
ErrorTypeGets the type of error that Avalonia.Data.BindingNotification.Error represents, if any.
HasValueGets a value indicating whether Avalonia.Data.BindingNotification.Value should be pushed to the target.
ValueGets the value that should be passed to the target when Avalonia.Data.BindingNotification.HasValue is true.

Error Property​

Gets the error that occurred on the source, if any.

public Exception Error { get; set; }

ErrorType Property​

Gets the type of error that Avalonia.Data.BindingNotification.Error represents, if any.

public Avalonia.Data.BindingErrorType ErrorType { get; set; }

HasValue Property​

Gets a value indicating whether Avalonia.Data.BindingNotification.Value should be pushed to the target.

public bool HasValue { get; set; }

Value Property​

Gets the value that should be passed to the target when Avalonia.Data.BindingNotification.HasValue is true.

public object Value { get; set; }

Remarks​

If this property is read when Avalonia.Data.BindingNotification.HasValue is false then it will return Avalonia.AvaloniaProperty.UnsetValue.

Fields​

NameDescription
NullA binding notification representing the null value.
UnsetValueA binding notification representing Avalonia.AvaloniaProperty.UnsetValue.

Null Field​

A binding notification representing the null value.

public Avalonia.Data.BindingNotification Null

UnsetValue Field​

A binding notification representing Avalonia.AvaloniaProperty.UnsetValue.

public Avalonia.Data.BindingNotification UnsetValue