TemplateProperty
TemplateProperty is a property used to link elements added as Template on .uxml with the View class.
When declared in a View class, the SourceGenerator collects the declared TemplateProperty.
For more on Template, see here.
How to Declare
As with BindableProperty, you can declare by calling TemplateProperty<T>.Create().
Set <T> as the type of the View you want to specify.
csharp
private static readonly TemplateProperty<CounterTemplate> TemplateViewProperty = TemplateProperty<CounterTemplate>.Create(
TemplateInfoList.ChildVmTemplate
);Parameters
TemplateProperty<T>.Create() can specify the following parameters:
| Parameter | Type | Required | Default Value |
|---|---|---|---|
| templateInfo | TemplateInfo | yes | - |
- templateInfo
Parameter for specifying theTemplatedeclared in .uxml.
Information forTemplatedeclared in .uxml is generated by the SourceGenerator asTemplateInfoList. The View specified bytemplateInfowill receive the ViewModel bound to the class that declared thisTemplateProperty<T>.
If you want to bind a ViewModel, the View class specified by<T>must inherit fromHaikaraViewModelProvidableBase.