Design-Time Layout Templates

  • 3 minutes to read

At design time, the Layout Control's Templates feature allows you to create common and frequently-used layouts with a few mouse clicks. Predefined templates shipped with the Layout Control provide common layout solutions out of the box. In addition, you can easily create a custom template from controls in your existing project and reuse this template in other projects.

Layout templates are available in the Templates tab in the Customization Form at design time.

LayoutControl-Templates

A template can be added to the LayoutControl using the drag-and-drop functionality. After dropping the template, all its elements are added to the LayoutControl. You can then rearrange and rename the added elements and change their settings in the Properties grid.

LayoutControlTemplates

Predefined Templates

The LayoutControl ships with a set of predefined templates. Several examples are shown below.

Template Name Layout
2x2 TextEdit LayoutControl2x2TextEditTemplate
Sign In Form LayoutControlSignInFormTemplate
Buttons Yes, No, Cancel LayoutControlButtonsYesNoCancelTemplate
Tabbed Empty Group LayoutControlTabbedEmptyGroupTemplate

Custom Templates

You can combine frequently used controls into a custom template and reuse it in other projects.

To create a new layout template, do the following:

  • At design time, select one or multiple layout items and choose the Create Template command from the context menu.

    TIP

    Multiple items can be selected while holding down the SHIFT or CTRL key.

    A template can only be created from a continuous rectangular selection.

    LayoutControlCreateTemplate

  • In the invoked Create Template dialog, type a new template name and click the Save button.

    LayoutControlEnterTemplateName

After that, the template will be available in the Customization Form's Templates tab.

LayoutControlUserTemplate

All custom templates are stored in the %Public%\Documents\DevExpress\XtraLayout\UserTemplates folder as XML files. If you wish to remove a specific custom template from the LayoutControl's Customization Form, delete the corresponding XML file.

Saving and Restoring Templates Notes

Take note of the following while saving and restoring templates.

  • A template can only be created from a continuous rectangular selection.
  • If a template contains a binding to a DataSet or an external assembly reference, the LayoutControl tries to remove this binding while restoring the template.
  • If you created a template with a UserControl, you can restore this control only in the same project. In other projects, the LayoutControl removes this UserControl when the template is restored.
  • If a template contains links to images from project resources, these images are not restored from this template. However, the LayoutControl supports saving and restoring images from form resources.
  • Event handlers are not included in templates.
See Also