BindingValue<T> Struct

Summary

A value passed into a binding.
Namespace
Avalonia.Data
Base Types
  • object
  • ValueType
graph BT Type-->Base0["ValueType"] Base0-->Base1["object"] Type["BindingValue<T>"] class Type type-node

Syntax

public readonly struct BindingValue<T> : ValueType

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 Type property: - Value: a simple value - UnsetValue: the target property will revert to its unbound state until a new binding value is produced. Represented by UnsetValue in an untyped context - DoNothing: the binding value will be ignored. Represented by DoNothing in an untyped context - BindingError: a binding error, such as a missing source property, with an optional fallback value - DataValidationError: a data validation error, with an optional fallback value To create a new binding value you can: - For a simple value, call the BindingValue<T> constructor or use an implicit conversion from T - For an unset value, use Unset or simply `default` - For other types, call one of the static factory methods

Type Parameters

Name Description
T The value type.

Constructors

Name Summary
BindingValue(T) Initializes a new instance of the BindingValue<T> struct with a type of Value

Properties

Name Value Summary
Error Exception?
Gets the binding or data validation error.
HasError bool
Gets a value indicating whether the binding value represents either a binding or data validation error.
HasValue bool
Gets a value indicating whether the binding value has a value.
Type BindingValueType
Gets the type of the binding value.
Value T
Gets the binding value or fallback value.

Methods

Name Value Summary
ToOptional() Optional<T>
Converts the binding value to an Optional<T>.
ToString() string
ToUntyped() object?
Converts the value to untyped representation, using UnsetValue, DoNothing and BindingNotification where appropriate.