Table of Contents

Class TemplateBinding

Namespace
Avalonia.Data
Assembly
Avalonia.Base.dll

A XAML binding to a property on a control's templated parent.

public class TemplateBinding : UntypedBindingExpressionBase, ISetterInstance, IBinding, IDescription, ISetterValue, IDisposable, IObserver<object?>, IObservable<object?>
Inheritance
TemplateBinding
Implements
Inherited Members
Extension Methods

Constructors

TemplateBinding()

public TemplateBinding()

TemplateBinding(AvaloniaProperty)

public TemplateBinding(AvaloniaProperty property)

Parameters

property AvaloniaProperty

Properties

Converter

Gets or sets the IValueConverter to use.

public IValueConverter? Converter { get; set; }

Property Value

IValueConverter

ConverterCulture

Gets or sets the culture in which to evaluate the converter.

[TypeConverter(typeof(CultureInfoIetfLanguageTagConverter))]
public CultureInfo? ConverterCulture { get; set; }

Property Value

CultureInfo

The default value is null.

Remarks

If this property is not set then CurrentCulture will be used.

ConverterParameter

Gets or sets a parameter to pass to Converter.

public object? ConverterParameter { get; set; }

Property Value

object

Description

Gets a description of the binding expression.

public override string Description { get; }

Property Value

string

Mode

Gets or sets the binding mode.

public BindingMode Mode { get; set; }

Property Value

BindingMode

Property

Gets or sets the name of the source property on the templated parent.

[InheritDataTypeFrom(InheritDataTypeFromScopeKind.ControlTemplate)]
public AvaloniaProperty? Property { get; set; }

Property Value

AvaloniaProperty

Methods

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

Initiates the binding on a target object.

public 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.

ProvideValue()

public IBinding ProvideValue()

Returns

IBinding

StartCore()

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

protected override void StartCore()

Remarks

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

StopCore()

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

protected override void StopCore()

Remarks

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

Subscribe(IObserver<object?>)

public IDisposable Subscribe(IObserver<object?> observer)

Parameters

observer IObserver<object>

Returns

IDisposable