Back to Devexpress

Template Customization

expressappframework-112696-ui-construction-templates-template-customization.md

latest9.3 KB
Original Source

Template Customization

  • Apr 03, 2026
  • 4 minutes to read

XAF built-in Templates generate UIs suitable for most business applications. You can modify these default templates or create fully custom templates at design time, or change template settings at runtime.

XAF determines the type of template to display based on TemplateContext. The following table lists the built-in XAF templates and their Contexts.

TemplateBlazor Template ClassWinForms Template ClassTemplate Context
Main Form Template (with a toolbar menu)ApplicationWindowTemplateLightStyleMainFormApplicationWindow
Main Ribbon Form TemplateApplicationRibbonWindowTemplateLightStyleMainRibbonFormApplicationWindow
Detail Form Template (with a toolbar menu)DetailFormTemplateDetailFormV2View
Detail Ribbon Form TemplateDetailRibbonFormTemplateDetailRibbonFormV2View
Popup Window/Form TemplatePopupWindowTemplatePopupFormPopupWindow
Nested Frame TemplateNestedFrameTemplateNestedFrameTemplateV2NestedFrame
Lookup Form TemplateLookupFormLookupWindow
Lookup Control TemplateLookupControlTemplateLookupControl
Logon Window TemplateLogonWindowTemplateLogonPopupFormLogonWindow

Create a Custom Template at Design Time

The DevExpress Template Kit allows you to add default XAF Template code to your application, customize it, and use your modified Templates instead of default Templates.

  1. Add Template code in your project (SolutionName.Blazor.Server or SolutionName.Win) as described in the following help topic: Template Kit: Create a new item.

  2. Modify the added template according to your needs.

  3. Handle the XafApplication.CreateCustomTemplate event to make the application to use your Template instead of the default Template. In the event handler, assign your Template class to the Template property.

Examples

Customize Template Settings at Runtime

Handle the XafApplication.CustomizeTemplate event to customize a Template every time it is created.

The following code sample accesses the Popup Window Template and specifies the template’s size limits.

csharp
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Blazor.Templates;

public class LimitPopupSizeController : WindowController {
    public LimitPopupSizeController() {
        TargetWindowType = WindowType.Main;
    }
    protected override void OnActivated() {
        base.OnActivated();
        Application.CustomizeTemplate += Application_CustomizeTemplate;
    }
    void Application_CustomizeTemplate(object sender, CustomizeTemplateEventArgs e) {
        if ((e.Context == TemplateContext.PopupWindow || e.Context == TemplateContext.LookupWindow)
            && e.Template is PopupWindowTemplate popupWindow) {
            popupWindow.MaxWidth = "900px";
            popupWindow.MaxHeight = "600px";
        }
    }
    protected override void OnDeactivated() {
        Application.CustomizeTemplate -= Application_CustomizeTemplate;
        base.OnDeactivated();
    }
}
csharp
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Win.Templates;

public class LimitPopupSizeController : WindowController {
    public LimitPopupSizeController() {
        TargetWindowType = WindowType.Main;
    }
    protected override void OnActivated() {
        base.OnActivated();
        Application.CustomizeTemplate += Application_CustomizeTemplate;
    }
    void Application_CustomizeTemplate(object sender, CustomizeTemplateEventArgs e) {
        if (e.Context == TemplateContext.PopupWindow && e.Template is PopupFormBase popupForm) {
            popupForm.MaximumSize = new Size(900, 600);
        }
    }
    protected override void OnDeactivated() {
        base.OnDeactivated();
        Application.CustomizeTemplate -= Application_CustomizeTemplate;
    }
}

Examples