Specifies a visual that contains templates that can override the default Templates provided in this object.

If specified together with TemplateKey, this instantiator will prefer to pick template from the specified TemplateSource that matches the TemplateKey property. If no match is found, it falls back to using the regular list of Templates. Refer to Defaults.

This property is useful if you are creating a component and want to allow certain templates inside the component to be overridden by the user.

Example

This example uses Each, but it applies equally to Instance and other subclasses of Instantiator.

<Panel ux:Class="MyListControl">
    <StackPanel>
        <Each Count="10" TemplateSource="this" TemplateKey="ListItem">
            <Text Value="This is an item" />
        </Each>
    </StackPanel>
</Panel>

If we instantiate <MyListControl> now, it will display the text "This is an item" 10 times.

However, we can override the template like this:

<MyListControl>
    <Rectangle ux:Template="ListItem" Color="Red">
        <Text>This is a red item</Text>
    </Rectangle>
</MyListControl>

This will display a red rectangle with the text "This is a red item" 10 times, instead of the default template defined in the component itself.

The TemplateSource property, along with the templates in the source, as well as the TemplateKey, must be set prior to rooting to take effect.

Location

Namespace
Fuse.Reactive
Package
Fuse.Reactive.Bindings 2.9.1

Returns

ITemplateSource