Table of Contents

Class FuncDataTemplate

Namespace
Avalonia.Controls.Templates
Assembly
Avalonia.Controls.dll

Builds a control for a piece of data.

public class FuncDataTemplate : FuncTemplate<object?, Control?>, IRecyclingDataTemplate, IDataTemplate, ITemplate<object?, Control?>
Inheritance
FuncDataTemplate
Implements
Derived
Inherited Members

Constructors

FuncDataTemplate(Func<object?, bool>, Func<object?, INameScope, Control?>, bool)

Initializes a new instance of the FuncDataTemplate class.

public FuncDataTemplate(Func<object?, bool> match, Func<object?, INameScope, Control?> build, bool supportsRecycling = false)

Parameters

match Func<object, bool>

A function which determines whether the data template matches the specified data.

build Func<object, INameScope, Control>

A function which returns a control for matching data.

supportsRecycling bool

Whether the control can be recycled.

FuncDataTemplate(Type, Func<object?, INameScope, Control?>, bool)

Initializes a new instance of the FuncDataTemplate class.

public FuncDataTemplate(Type type, Func<object?, INameScope, Control?> build, bool supportsRecycling = false)

Parameters

type Type

The type of data which the data template matches.

build Func<object, INameScope, Control>

A function which when passed an object of type returns a control.

supportsRecycling bool

Whether the control can be recycled.

Fields

Access

The default data template used in the case where no matching data template is found but AccessText should be used.

public static readonly FuncDataTemplate Access

Field Value

FuncDataTemplate

Default

The default data template used in the case where no matching data template is found.

public static readonly FuncDataTemplate Default

Field Value

FuncDataTemplate

Methods

Build(object?, Control?)

Creates or recycles a control to display the specified data.

public Control? Build(object? data, Control? existing)

Parameters

data object

The data to display.

existing Control

An optional control to recycle.

Returns

Control

The existing control if supplied and applicable to data, otherwise a new control or null.

Remarks

The caller should ensure that any control passed to existing originated from the same data template.

Match(object?)

Checks to see if this data template matches the specified data.

public bool Match(object? data)

Parameters

data object

The data.

Returns

bool

True if the data template can build a control for the data, otherwise false.