Table of Contents

Class UntypedBindingExpressionBase

Namespace
Avalonia.Data.Core
Assembly
Avalonia.Base.dll

Base class for binding expressions which produce untyped values.

[PrivateApi]
public abstract class UntypedBindingExpressionBase : BindingExpressionBase, ISetterInstance, IDisposable, IDescription
Inheritance
UntypedBindingExpressionBase
Implements
Derived
Inherited Members

Constructors

UntypedBindingExpressionBase(BindingPriority, AvaloniaProperty?, bool)

Initializes a new instance of the UntypedBindingExpressionBase class.

public UntypedBindingExpressionBase(BindingPriority defaultPriority, AvaloniaProperty? targetProperty = null, bool isDataValidationEnabled = false)

Parameters

defaultPriority BindingPriority

The default binding priority for the expression.

targetProperty AvaloniaProperty

The target property being bound to.

isDataValidationEnabled bool

Whether data validation is enabled.

Fields

UnchangedValue

protected static readonly object UnchangedValue

Field Value

object

Properties

Description

Gets a description of the binding expression.

public abstract string Description { get; }

Property Value

string

ErrorType

Gets the current error state of the binding expression.

public BindingErrorType ErrorType { get; }

Property Value

BindingErrorType

IsDataValidationEnabled

Gets a value indicating whether data validation is enabled for the binding expression.

public bool IsDataValidationEnabled { get; }

Property Value

bool

IsRunning

Gets a value indicating whether the binding expression is currently running.

public bool IsRunning { get; }

Property Value

bool

Priority

Gets the priority of the binding expression.

public BindingPriority Priority { get; }

Property Value

BindingPriority

Remarks

Before being attached to a value store, this property describes the default priority of the binding expression; this may change when the expression is attached to a value store.

TargetProperty

Gets the AvaloniaProperty which the binding expression is targeting.

public AvaloniaProperty? TargetProperty { get; }

Property Value

AvaloniaProperty

TargetType

Gets the target type of the binding expression; that is, the type that values produced by the expression should be converted to.

public Type TargetType { get; }

Property Value

Type

Methods

ConvertBack(IValueConverter, CultureInfo?, object?, object?, Type)

Converts a value using a value converter's ConvertBack method, logging a warning if necessary.

protected object? ConvertBack(IValueConverter converter, CultureInfo? converterCulture, object? converterParameter, object? value, Type targetType)

Parameters

converter IValueConverter

The value converter.

converterCulture CultureInfo

The culture to use for the conversion.

converterParameter object

The converter parameter.

value object

The value to convert.

targetType Type

The target type to convert to.

Returns

object

The converted value, or UnsetValue if an error occurred; in which case the error will be logged.

Dispose()

Terminates the binding.

public override void Dispose()

GetValue()

Gets the current value of the binding expression.

public object? GetValue()

Returns

object

The current value or UnsetValue if the binding was unable to read a value.

Exceptions

InvalidOperationException

The binding expression has not been started.

GetValueOrDefault()

Gets the current value of the binding expression or the default value for the target property.

public object? GetValueOrDefault()

Returns

object

The current value or the target property default.

Log(AvaloniaObject, string, LogEventLevel)

Logs a binding error.

protected void Log(AvaloniaObject target, string error, LogEventLevel level = LogEventLevel.Warning)

Parameters

target AvaloniaObject

The target of the binding expression.

error string

The error message.

level LogEventLevel

The log level.

Log(string, LogEventLevel)

Logs a binding error.

protected void Log(string error, LogEventLevel level = LogEventLevel.Warning)

Parameters

error string

The error message.

level LogEventLevel

The log level.

ShouldLogError(out AvaloniaObject?)

Gets a value indicating whether an error should be logged given the current state of the binding expression.

protected virtual bool ShouldLogError(out AvaloniaObject? target)

Parameters

target AvaloniaObject

When the method returns, contains the target object, if it is available.

Returns

bool

True if an error should be logged; otherwise false.

Start()

Starts the binding expression following a call to Avalonia.Data.Core.UntypedBindingExpressionBase.AttachCore(Avalonia.Data.Core.IBindingExpressionSink,Avalonia.PropertyStore.ImmediateValueFrame,Avalonia.AvaloniaObject,Avalonia.AvaloniaProperty,Avalonia.Data.BindingPriority).

public void Start()

Start(bool)

Starts the binding expression by calling StartCore().

protected void Start(bool produceValue)

Parameters

produceValue bool

Indicates whether the binding expression should produce an initial value.

StartCore()

When overridden in a derived class, starts the binding expression.

protected abstract void StartCore()

Remarks

This method should not be called directly; instead call Start(bool).

Stop()

Stops the binding expression by calling StopCore().

protected void Stop()

StopCore()

When overridden in a derived class, stops the binding expression.

protected abstract void StopCore()

Remarks

This method should not be called directly; instead call Stop().

TryGetTarget(out AvaloniaObject?)

Tries to retrieve the target for the binding expression.

protected bool TryGetTarget(out AvaloniaObject? target)

Parameters

target AvaloniaObject

When this method returns, contains the target object, if it is available.

Returns

bool

true if the target was retrieved; otherwise, false.