Table of Contents

Class Binding

Namespace
Avalonia.Data
Assembly
Avalonia.Markup.dll

A XAML binding.

public class Binding : BindingBase, IBinding
Inheritance
Binding
Implements
Inherited Members

Constructors

Binding()

Initializes a new instance of the Binding class.

public Binding()

Binding(string, BindingMode)

Initializes a new instance of the Binding class.

public Binding(string path, BindingMode mode = BindingMode.Default)

Parameters

path string

The binding path.

mode BindingMode

The binding mode.

Properties

ElementName

Gets or sets the name of the element to use as the binding source.

public string? ElementName { get; set; }

Property Value

string

Path

Gets or sets the binding path.

public string Path { get; set; }

Property Value

string

RelativeSource

Gets or sets the relative source for the binding.

public RelativeSource? RelativeSource { get; set; }

Property Value

RelativeSource

Source

Gets or sets the source for the binding.

public object? Source { get; set; }

Property Value

object

TypeResolver

Gets or sets a function used to resolve types from names in the binding path.

public Func<string?, string, Type>? TypeResolver { get; set; }

Property Value

Func<string, string, Type>

Methods

Initiate(AvaloniaObject, AvaloniaProperty?, object?, bool)

Initiates the binding on a target object.

[Obsolete("This API may be removed in Avalonia 12. If you depend on this API, please open an issue with details of your use-case.")]
public override InstancedBinding? Initiate(AvaloniaObject target, AvaloniaProperty? targetProperty, object? anchor = null, bool enableDataValidation = false)

Parameters

target AvaloniaObject

The target instance.

targetProperty AvaloniaProperty

The target property. May be null.

anchor object

An optional anchor from which to locate required context. When binding to objects that are not in the logical tree, certain types of binding need an anchor into the tree in order to locate named controls or resources. The anchor parameter can be used to provide this context.

enableDataValidation bool

Whether data validation should be enabled.

Returns

InstancedBinding

A InstancedBinding or null if the binding could not be resolved.