Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Collapse]eXpressApp Framework
 [Expand]Fundamentals
 [Expand]Getting Started
 [Expand]Concepts
 [Expand]Design-Time Features
 [Expand]Functional Testing
 [Expand]Deployment
 [Collapse]Task-Based Help
  [Expand]Business Model Design
  [Expand]Application Model
  [Expand]Actions
  [Expand]Navigation
  [Expand]Views
  [Expand]List Editors
  [Expand]Property Editors
  [Collapse]Templates
    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]Filtering
  [Expand]Reporting
  [Expand]Dashboards
  [Expand]Scheduler and Notifications
  [Expand]Maps
  [Expand]Security
  [Expand]Workflow
  [Expand]Localization
  [Expand]Testing
  [Expand]Miscellaneous UI Customizations
 [Expand]Frequently Asked Questions
 [Expand]API Reference
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
[Expand]End-User Documentation

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.

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, DefaultFrameTemplateFactory. 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 DefaultFrameTemplateFactory 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 DefaultFrameTemplateFactory 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).

How would you rate this topic?​​​​​​​