About Templates

Templates are a simple but very powerful feature that you can use with your Vision windows. Using templates, you would define the graphics and parameters in one place, called the master template. You then create instances throughout your project that update whenever the master/parent template is changed.

To create a Template

  1. Right-click the Templates node in the Project Browser and choose New Template from the menu.
    Or you can choose File > New > New Template from the Designer's menu bar.

    A checkered box is displayed in the Designer's workspace.

  2. Configure the master template the same way you would design windows: by adding components to it, and configuring those components using property bindings and scripting.

    See Basic Template for detailed information on creating a template.

Using the Template

Once you have a template, here are some of the things you can do with it.

Renaming the Template

You can rename your template by clicking on its name in the Project Browser and pressing F2, or changing the name in the Property Editor.

Creating the Template Instances

Once you've made your template, you can use it on any of the windows in your project by doing any one of the following steps:

  • You can drag the template from the Project Browser into an open window just like you can drag components into the window for display.

  • You can right-click on the template and choose Use In Window, which will let you place the template inside a window with another click.

  • You can drag a tag from the Tag Browser to a window and from the pop-up menu, which is displayed, you can choose a template.

The template instance can then be moved and resized like any other component.

Binding Template Properties

Templates have the capability to incorporate custom properties. In this way, they are the same as any other Ignition components. The main difference between the custom properties for an Ignition component and a template is that the template has internal properties and template parameters.

  • Internal Properties
    Internal properties help facilitate the bindings within a template in the same way that a window's root container will help facilitate bindings between components that make up the template. When a template is deployed onto a window the internal custom properties are not exposed to the world outside the template.

  • Template Parameters
    The template parameters are the template's custom properties that are exposed to the outside world. In other words, when a template is deployed onto the root container of a window, the template parameters are available for binding with the objects on that window or to tags.

Editing a Template

You can open a template for editing by double-clicking on it in the Project Browser, or by double-clicking any instance of that template within a window. You design your template the same way you design windows: by adding components to it, and configuring those components using property bindings and scripting.

There are a few differences between templates and windows from an editing perspective. Templates, unlike windows, have a transparent background by default. This can be changed simply by editing the background color of the template. Templates also do not have the concept of the "Root Container" - the template itself acts like a container.

Once you change the master template, all the instances of that template are updated.

Next...