Share via


DataTemplate Class

Definition

Defines the visual structure for templated items. Used to display data objects with a consistent appearance.

public ref class DataTemplate : Microsoft::Maui::Controls::ElementTemplate, Microsoft::Maui::Controls::Internals::IDataTemplateController
public class DataTemplate : Microsoft.Maui.Controls.ElementTemplate, Microsoft.Maui.Controls.Internals.IDataTemplateController
type DataTemplate = class
    inherit ElementTemplate
    interface IDataTemplateController
Public Class DataTemplate
Inherits ElementTemplate
Implements IDataTemplateController
Inheritance
DataTemplate
Derived
Implements

Remarks

In XAML, application developers can nest markup inside a DataTemplate tag to create a View whose members are bound to the properties of data objects that are contained in a ItemsSource list.

Constructors

Name Description
DataTemplate()

Initializes a new instance of the DataTemplate class.

DataTemplate(Func<Object>)

Initializes a new instance with a factory function that creates template content.

DataTemplate(Type)

Initializes a new instance of the DataTemplate class with the specified type.

Properties

Name Description
Bindings

Gets the dictionary of bindings to apply to templated items.

LoadTemplate (Inherited from ElementTemplate)
Values

Gets the dictionary of property values to apply to templated items.

Methods

Name Description
CreateContent()

Used by the XAML infrastructure to load data templates and set up the content of the resulting UI.

(Inherited from ElementTemplate)
SetBinding(BindableProperty, BindingBase)

Sets a binding for a property on templated items.

SetValue(BindableProperty, Object)

Sets a static value for a property on templated items.

Explicit Interface Implementations

Name Description
IDataTemplateController.Id
IDataTemplateController.IdString

Extension Methods

Name Description
CreateContent(DataTemplate, Object, BindableObject)

Selects the appropriate template and creates its content for the specified item.

SelectDataTemplate(DataTemplate, Object, BindableObject)

Returns the appropriate template, invoking selector logic if the template is a DataTemplateSelector.

SetBinding(DataTemplate, BindableProperty, String)

Creates a binding on the template for the specified property and path.

Applies to