Table of Contents

Class Binding

Namespace
Icy.Data.Bindings
Assembly
IcyUI.dll

Represents a class for property binding. It provides automatic property update for supported objects.

public sealed class Binding : IBinding, IDisposable
Inheritance
Binding
Implements
Inherited Members
Extension Methods

Remarks

This binding implementation can dynamically change source objects and binding modes.

Constructors

Binding(IBindingTarget, IPropertyReference, IPropertyPath)

Initializes a new instance of the Binding class.

public Binding(IBindingTarget target, IPropertyReference targetProperty, IPropertyPath sourceProperty)

Parameters

target IBindingTarget

Target object to bind.

targetProperty IPropertyReference

Property of the target object to bind to.

sourceProperty IPropertyPath

Property path of the source object to access.

Binding(IPropertyPath)

Initializes a new instance of the Binding class.

public Binding(IPropertyPath sourceProperty)

Parameters

sourceProperty IPropertyPath

Property path of the source object to access.

Remarks

Note that this initializer makes incomplete binding that is not ready for work. You'll need to call Bind(IBinding) with the created instance to complete the binding.

Properties

ConverterParameters

Gets or sets the parameters for the value conversion.

public BindingConverterParameters? ConverterParameters { get; set; }

Property Value

BindingConverterParameters

Culture

Gets or sets the culture this binding formats values as text and parses text into values with, or null (the default) to use the configuration's.

public CultureInfo? Culture { get; set; }

Property Value

CultureInfo

Remarks

While unset, the culture is looked up at each conversion, in this order:

  1. the Culture of the canvas the target element is attached to;
  2. the configuration that loaded the binding from markup, for a target that isn't attached yet;
  3. CurrentUICulture.

It also applies to the ConverterParameters converter when that has no culture of its own.

ElementName

Gets or sets the name of the UI element that should be used as the binding source.

public string? ElementName { get; set; }

Property Value

string

Error

Gets the failure that put this binding into its error state, or null when there is none.

public Exception? Error { get; }

Property Value

Exception

Remarks

For example the type converter's exception for text that doesn't parse, or the exception the source property's own setter threw. Exceptions wrapped in TargetInvocationException are unwrapped.

FallbackValue

Gets or sets the value that is set when the binding cannot return the value.

public object? FallbackValue { get; set; }

Property Value

object

HasError

Gets a value indicating whether the last write to the source failed.

public bool HasError { get; }

Property Value

bool

Remarks

Writing to the source never throws for a bad value: the source keeps its previous value and this flag is set instead (see Error). It clears on the next successful write in either direction.

When the target is a UIElement, the element carries Invalid while any of its bindings has an error, so styles can show it.

IsEnabled

Gets or sets a value indicating whether the binding is enabled and listening to updates.

public bool IsEnabled { get; set; }

Property Value

bool

Mode

Gets or sets a value defining the direction of the binding.

public BindingMode Mode { get; set; }

Property Value

BindingMode

Path

Gets the property path to the source object to get values from.

public IPropertyPath Path { get; }

Property Value

IPropertyPath

Source

Gets or sets the source object to access.

public object? Source { get; set; }

Property Value

object

Target

Gets the target object to set values to.

[MemberNotNull("target")]
public IBindingTarget Target { get; }

Property Value

IBindingTarget

TargetNullValue

Gets or sets the value of the target property that is set when the source returns null.

public object? TargetNullValue { get; set; }

Property Value

object

TargetProperty

Gets or sets the property of the target object to access.

public IPropertyReference TargetProperty { get; set; }

Property Value

IPropertyReference

UpdateSourceTrigger

Gets or sets a value defining target triggers to update source property.

public UpdateSourceTrigger UpdateSourceTrigger { get; set; }

Property Value

UpdateSourceTrigger

UpdateTargetTrigger

Gets or sets a value indicating when the binding refreshes its target from its source.

public UpdateTargetTrigger UpdateTargetTrigger { get; set; }

Property Value

UpdateTargetTrigger

Methods

DestroyBinding()

Unsubscribe from source and target objects.

public void DestroyBinding()

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

~Binding()

Finalizes an instance of the Binding class.

protected ~Binding()

UpdateSource()

Force update source object from target object.

public void UpdateSource()

UpdateTarget()

Force update target object from source object.

public void UpdateTarget()

Events

ErrorChanged

Occurs when HasError changes, or when Error changes while HasError stays true.

public event EventHandler? ErrorChanged

Event Type

EventHandler