Log In
[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Collapse]eXpressApp Framework
 [Expand]Getting Started
 [Expand]Design-Time Features
 [Collapse]Task-Based Help
  [Expand]Business Model Design
  [Expand]Application Model
  [Expand]List Editors
  [Expand]Property Editors
    How to: Access the Bar Manager
    How to: Access the Document Manager
    How to: Access the Ribbon Control
    How to: Create a Custom WinForms Ribbon Template
    How to: Create a Custom WinForms Standard Template
    How to: Customize an ASP.NET Template
    How to: Distribute Custom Templates with Modules
  [Expand]Scheduler and Notifications
  [Expand]Miscellaneous UI Customizations
  Frequently Asked Questions (FAQ)
 [Expand]API Reference
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
This documentation page describes implementations made in our v17.2 release cycle. To learn about functionality shipping with v18.1, navigate to our updated help file experience at docs.devexpress.com. Learn More

How to: Distribute Custom Templates with Modules

The eXpressApp Framework uses default Templates when constructing Windows Forms UIs. You can customize them. Approaches for customization are defined in the Template Customization and How to: Create a Custom WinForms Ribbon Template topics. Once you have developed a custom Template, you may need to use it in several applications. The appropriate way to distribute Windows Forms Templates is to add them to a module that will then be added to the required Windows Forms applications. This topic demonstrates how to do this. ASP.NET templates can be easily distributed, as is. You can add them to an ASP.NET application project replacing the defaults.


The approach described in this topic is not supported by the Mobile platform. If it is necessary to implement this scenario in your Mobile application, contact us using the Support Center.

When constructing a Windows Forms UI, the WinApplication class instance uses its Frame Template Factory to create a Template that is appropriate in the current context. A Frame Template Factory is a class that implements the IFrameTemplateFactory interface. This interface exposes a single method, CreateTemplate, that gets the current Template context as a parameter. The eXpressApp Framework has a base class that implements this interface, FrameTemplateFactoryBase, and its descendant, DefaultLightStyleFrameTemplateFactory. The base class exposes abstract methods that are called by the CreateTemplate method, dependent on the passed Template context. They are: CreateNestedFrameTemplate, CreatePopupWindowTemplate, CreateLookupControlTemplate, CreateLookupWindowTemplate, CreateApplicationWindowTemplate and CreateViewTemplate. The DefaultLightStyleFrameTemplateFactory class overrides these methods to create the default XAF Templates.

To make an application use custom Templates, do the following:

  • Add the custom Templates to the module project to be distributed.
  • Implement a Frame Template Factory class in the module to be distributed.

    This class should return the required custom Template in an appropriate context. The code below demonstrates how to implement this for two custom Templates: the MyMainForm Template, which is created to represent the main Window, and the MyDetailViewForm Template, which is created to represent a detail form. These templates have custom constructors taking an IModelTemplate object as the only parameter, for initialization purposes. The newly implemented MyFrameTemplateFactory class is inherited from the DefaultLightStyleFrameTemplateFactory class, to override the CreateApplicationWindowTemplate and CreateViewTemplate methods only.

  • Set the custom Frame Template Factory for the application.
    To make the application use the custom Frame Template Factory to create Templates, set it for the WinApplication.FrameTemplateFactory property in the Setup method of the distributed module. The following code demonstrates this:
  • Compile the module project and add it to the required application project (see Application Solution Structure).

Is this topic helpful?​​​​​​​