Table of Contents

Class BindingNotification

Namespace
Avalonia.Data
Assembly
Avalonia.Base.dll

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

public class BindingNotification
Inheritance
BindingNotification
Inherited Members

Remarks

This class is very similar to BindingValue<T>, but where 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

BindingNotification(Exception, BindingErrorType)

Initializes a new instance of the BindingNotification class.

public BindingNotification(Exception error, BindingErrorType errorType)

Parameters

error Exception

The binding error.

errorType BindingErrorType

The type of the binding error.

BindingNotification(Exception, BindingErrorType, object?)

Initializes a new instance of the BindingNotification class.

public BindingNotification(Exception error, BindingErrorType errorType, object? fallbackValue)

Parameters

error Exception

The binding error.

errorType BindingErrorType

The type of the binding error.

fallbackValue object

The fallback value.

BindingNotification(object?)

Initializes a new instance of the BindingNotification class.

public BindingNotification(object? value)

Parameters

value object

The binding value.

Fields

Null

A binding notification representing the null value.

public static readonly BindingNotification Null

Field Value

BindingNotification

UnsetValue

A binding notification representing UnsetValue.

public static readonly BindingNotification UnsetValue

Field Value

BindingNotification

Properties

Error

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

public Exception? Error { get; set; }

Property Value

Exception

ErrorType

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

public BindingErrorType ErrorType { get; set; }

Property Value

BindingErrorType

HasValue

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

public bool HasValue { get; }

Property Value

bool

Value

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

public object? Value { get; }

Property Value

object

Remarks

If this property is read when HasValue is false then it will return UnsetValue.

Methods

AddError(Exception, BindingErrorType)

Adds an error to the BindingNotification.

public void AddError(Exception e, BindingErrorType type)

Parameters

e Exception

The error to add.

type BindingErrorType

The error type.

ClearValue()

Removes the Value and makes HasValue return null.

public void ClearValue()

Equals(BindingNotification?)

Compares a value to an instance of BindingNotification for equality.

public bool Equals(BindingNotification? other)

Parameters

other BindingNotification

The value to compare.

Returns

bool

true if the two instances are equal; otherwise false.

Equals(object?)

Compares an object to an instance of BindingNotification for equality.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare.

Returns

bool

true if the two instances are equal; otherwise false.

ExtractError(object?)

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

public static object? ExtractError(object? o)

Parameters

o object

The object.

Returns

object

The value.

Remarks

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

ExtractValue(object?)

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

public static object? ExtractValue(object? o)

Parameters

o object

The object.

Returns

object

The value.

Remarks

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

GetHashCode()

Gets the hash code for this instance of BindingNotification.

public override int GetHashCode()

Returns

int

A hash code.

SetValue(object?)

Sets the Value.

public void SetValue(object? value)

Parameters

value object

ToString()

public override string ToString()

Returns

string

UpdateValue(object?, object)

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

public static 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 BindingNotification then sets its value to value. If value is a BindingNotification then the value will first be extracted.

Operators

operator ==(BindingNotification?, BindingNotification?)

Compares two instances of BindingNotification for equality.

public static bool operator ==(BindingNotification? a, BindingNotification? b)

Parameters

a BindingNotification

The first instance.

b BindingNotification

The second instance.

Returns

bool

true if the two instances are equal; otherwise false.

operator !=(BindingNotification?, BindingNotification?)

Compares two instances of BindingNotification for inequality.

public static bool operator !=(BindingNotification? a, BindingNotification? b)

Parameters

a BindingNotification

The first instance.

b BindingNotification

The second instance.

Returns

bool

true if the two instances are unequal; otherwise false.