Skip to main content

BindingValue<T> Struct

Definition​

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

A value passed into a binding.

public struct BindingValue<T>

Inheritance: ValueType -> BindingValue<T>

Implements: IEquatable<BindingValue<>>

Remarks​

The avalonia binding system is typed, and as such additional state is stored in this structure. A binding value can be in a number of states, described by the Avalonia.Data.BindingValue<T>.Type property:

To create a new binding value you can:

Constructors​

NameDescription
BindingValue<T>Initializes a new instance of the Avalonia.Data.BindingValue<T> struct with a type of Avalonia.Data.BindingValueType.Value

BindingValue<T> Constructor​

Initializes a new instance of the Avalonia.Data.BindingValue<T> struct with a type of Avalonia.Data.BindingValueType.Value

public BindingValue<T>(T value)

Parameters​

value T

The value.

Methods​

NameDescription
BindingError (3 overloads)Returns a binding value with a type of Avalonia.Data.BindingValueType.BindingError.
DataValidationError (3 overloads)Returns a binding value with a type of Avalonia.Data.BindingValueType.DataValidationError.
Equals (2 overloads)No summary available.
FromUntyped (2 overloads)Creates a Avalonia.Data.BindingValue<T> from an object, handling the special values Avalonia.AvaloniaProperty.UnsetValue, Avalonia.Data.BindingOperations.DoNothing and Avalonia.Data.BindingNotification.
GetHashCodeNo summary available.
GetValueOrDefault (3 overloads)Gets the value of the binding value if present, otherwise the default value.
ToOptionalConverts the binding value to an Avalonia.Data.Optional<T>.
ToStringNo summary available.
ToUntypedConverts the value to untyped representation, using Avalonia.AvaloniaProperty.UnsetValue, Avalonia.Data.BindingOperations.DoNothing and Avalonia.Data.BindingNotification where appropriate.
WithValueReturns a new binding value with the specified value.

BindingError overloads​

BindingError Method​

Returns a binding value with a type of Avalonia.Data.BindingValueType.BindingError.

public Avalonia.Data.BindingValue<T><T> BindingError(Exception e)
Parameters​

e Exception

The binding error.

Returns​

Avalonia.Data.BindingValue<T><T>

BindingError Method​

public Avalonia.Data.BindingValue<T><T> BindingError(Exception e, Avalonia.Data.Optional<T><T> fallbackValue)
Parameters​

e Exception

fallbackValue Avalonia.Data.Optional<T><T>

Returns​

Avalonia.Data.BindingValue<T><T>

BindingError Method​

Returns a binding value with a type of Avalonia.Data.BindingValueType.BindingErrorWithFallback.

public Avalonia.Data.BindingValue<T><T> BindingError(Exception e, T fallbackValue)
Parameters​

e Exception

The binding error.

fallbackValue T

The fallback value.

Returns​

Avalonia.Data.BindingValue<T><T>

DataValidationError overloads​

DataValidationError Method​

Returns a binding value with a type of Avalonia.Data.BindingValueType.DataValidationError.

public Avalonia.Data.BindingValue<T><T> DataValidationError(Exception e)
Parameters​

e Exception

The data validation error.

Returns​

Avalonia.Data.BindingValue<T><T>

DataValidationError Method​

public Avalonia.Data.BindingValue<T><T> DataValidationError(Exception e, Avalonia.Data.Optional<T><T> fallbackValue)
Parameters​

e Exception

fallbackValue Avalonia.Data.Optional<T><T>

Returns​

Avalonia.Data.BindingValue<T><T>

DataValidationError Method​

Returns a binding value with a type of Avalonia.Data.BindingValueType.DataValidationErrorWithFallback.

public Avalonia.Data.BindingValue<T><T> DataValidationError(Exception e, T fallbackValue)
Parameters​

e Exception

The data validation error.

fallbackValue T

The fallback value.

Returns​

Avalonia.Data.BindingValue<T><T>

Equals overloads​

Equals Method​

public bool Equals(Avalonia.Data.BindingValue<T><T> other)
Parameters​

other Avalonia.Data.BindingValue<T><T>

Returns​

bool

Equals Method​

public bool Equals(object obj)
Parameters​

obj object

Returns​

bool

FromUntyped overloads​

FromUntyped Method​

Creates a Avalonia.Data.BindingValue<T> from an object, handling the special values Avalonia.AvaloniaProperty.UnsetValue, Avalonia.Data.BindingOperations.DoNothing and Avalonia.Data.BindingNotification.

public Avalonia.Data.BindingValue<T><T> FromUntyped(object value)
Parameters​

value object

The untyped value.

Returns​

Avalonia.Data.BindingValue<T><T>

The typed binding value.

FromUntyped Method​

Creates a Avalonia.Data.BindingValue<T> from an object, handling the special values Avalonia.AvaloniaProperty.UnsetValue, Avalonia.Data.BindingOperations.DoNothing and Avalonia.Data.BindingNotification.

public Avalonia.Data.BindingValue<T><T> FromUntyped(object value, Type targetType)
Parameters​

value object

The untyped value.

targetType Type

The runtime target type.

Returns​

Avalonia.Data.BindingValue<T><T>

The typed binding value.

GetHashCode Method​

public int GetHashCode()

Returns​

int

GetValueOrDefault overloads​

GetValueOrDefault Method​

Gets the value of the binding value if present, otherwise the default value.

public TResult GetValueOrDefault<TResult>()
Returns​

T

The value.

GetValueOrDefault Method​

Gets the value of the binding value if present, otherwise a default value.

public T GetValueOrDefault(T defaultValue)
Parameters​

defaultValue T

The default value.

Returns​

T

The value.

GetValueOrDefault Method​

public TResult GetValueOrDefault<TResult>(TResult defaultValue)
Parameters​

defaultValue TResult

Type Parameters​

TResult

Returns​

TResult

ToOptional Method​

Converts the binding value to an Avalonia.Data.Optional<T>.

public Avalonia.Data.Optional<T><T> ToOptional()

Returns​

Avalonia.Data.Optional<T><T>

ToString Method​

public string ToString()

Returns​

string

ToUntyped Method​

Converts the value to untyped representation, using Avalonia.AvaloniaProperty.UnsetValue, Avalonia.Data.BindingOperations.DoNothing and Avalonia.Data.BindingNotification where appropriate.

public object ToUntyped()

Returns​

object

The untyped representation of the binding value.

WithValue Method​

Returns a new binding value with the specified value.

public Avalonia.Data.BindingValue<T><T> WithValue(T value)

Parameters​

value T

The new value.

Returns​

Avalonia.Data.BindingValue<T><T>

The new binding value.

Exceptions​

Properties​

NameDescription
DoNothingReturns a binding value with a type of Avalonia.Data.BindingValueType.DoNothing.
ErrorGets the binding or data validation error.
HasErrorGets a value indicating whether the binding value represents either a binding or data validation error.
HasValueGets a value indicating whether the binding value has a value.
TypeGets the type of the binding value.
UnsetReturns a binding value with a type of Avalonia.Data.BindingValueType.UnsetValue.
ValueGets the binding value or fallback value.

DoNothing Property​

Returns a binding value with a type of Avalonia.Data.BindingValueType.DoNothing.

public Avalonia.Data.BindingValue<T><T> DoNothing { get; set; }

Error Property​

Gets the binding or data validation error.

public Exception Error { get; set; }

HasError Property​

Gets a value indicating whether the binding value represents either a binding or data validation error.

public bool HasError { get; set; }

HasValue Property​

Gets a value indicating whether the binding value has a value.

public bool HasValue { get; set; }

Type Property​

Gets the type of the binding value.

public Avalonia.Data.BindingValueType Type { get; set; }

Unset Property​

Returns a binding value with a type of Avalonia.Data.BindingValueType.UnsetValue.

public Avalonia.Data.BindingValue<T><T> Unset { get; set; }

Value Property​

Gets the binding value or fallback value.

public T Value { get; set; }

Exceptions​