TemplateHost
in namespace DotVVM.Framework.Controls
Renders a template supplied by a resource binding or from a runtime.
Usage & Scenarios
This control allows to host a template (an ITemplate
object) and build its contents using this template.
The control is not meant to be used in DotHTML markup - it helps the control developers to place template inside another controls at a later time.
public class MyMenu : CompositeControl
{
public static DotvvmControl GetContents(
// please note that appropriate DataContextChange attributes need to be applied here as the template is used inside Repeater
ITemplate itemTemplate,
...
)
{
return new Repeater()
...
.SetProperty(r => r.ItemTemplate, new DelegateTemplate(serviceProvider =>
new HtmlGenericControl("li")
.AppendChildren(new TemplateHost(itemTemplate))
));
}
}
See also
Properties
Name | Type | Description | Notes | Default Value | |
---|---|---|---|---|---|
ClientIDMode | ClientIDMode | Gets or sets the client ID generation algorithm. |
attribute
static value
|
Static | |
DataContext | Object | Gets or sets a data context for the control and its children. All value and command bindings are evaluated in context of this value. The DataContext is null in client-side templates. |
attribute
bindable
|
null | |
ID | String | Gets or sets the control client ID within its naming container. |
attribute
static value
bindable
|
null | |
IncludeInPage | Boolean | Gets or sets whether the control is included in the DOM of the page. |
attribute
bindable
|
True | |
Template | ITemplate | Gets or sets the template that will be rendered inside this control. |
attribute
static value
|
null |