Class UntypedBindingExpressionBase
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
BindingPriorityThe default binding priority for the expression.
targetProperty
AvaloniaPropertyThe target property being bound to.
isDataValidationEnabled
boolWhether data validation is enabled.
Fields
UnchangedValue
protected static readonly object UnchangedValue
Field Value
Properties
Description
Gets a description of the binding expression.
public abstract string Description { get; }
Property Value
ErrorType
Gets the current error state of the binding expression.
public BindingErrorType ErrorType { get; }
Property Value
IsDataValidationEnabled
Gets a value indicating whether data validation is enabled for the binding expression.
public bool IsDataValidationEnabled { get; }
Property Value
IsRunning
Gets a value indicating whether the binding expression is currently running.
public bool IsRunning { get; }
Property Value
Priority
Gets the priority of the binding expression.
public BindingPriority Priority { get; }
Property Value
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
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
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
IValueConverterThe value converter.
converterCulture
CultureInfoThe culture to use for the conversion.
converterParameter
objectThe converter parameter.
value
objectThe value to convert.
targetType
TypeThe 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
AvaloniaObjectThe target of the binding expression.
error
stringThe error message.
level
LogEventLevelThe log level.
Log(string, LogEventLevel)
Logs a binding error.
protected void Log(string error, LogEventLevel level = LogEventLevel.Warning)
Parameters
error
stringThe error message.
level
LogEventLevelThe 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
AvaloniaObjectWhen 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
boolIndicates 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
AvaloniaObjectWhen this method returns, contains the target object, if it is available.
Returns
- bool
true if the target was retrieved; otherwise, false.