XafApplication.CustomizeTemplate Event

Occurs after a Template has been created.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v18.2.dll

Declaration

public event EventHandler<CustomizeTemplateEventArgs> CustomizeTemplate
Public Event CustomizeTemplate As EventHandler(Of CustomizeTemplateEventArgs)

The CustomizeTemplate event handler receives an argument of the CustomizeTemplateEventArgs type. The following properties provide information specific to this event.

Property Description
Context Returns the context in which the Template to be customized was created.
Template Provides access to the Template to be customized.

In Windows Forms applications, this event is raised after a Template has been created and before it is set for a Window. Handle this event to customize a particular Template. For this purpose, use the handler's CustomizeTemplateEventArgs.Context or CustomizeTemplateEventArgs.Template parameter. For details, refer to the Template Customization and How to: Access Navigation Control topics.

The following code snippet demonstrates how to hide toolbars accompanying a nested List View in a Windows Forms XAF application by handling the CustomizeTemplate event.

using DevExpress.ExpressApp.Templates;
//...
public class MyHideToolbarController : Controller {
    protected override void OnActivated() {
        base.OnActivated();
        Application.CustomizeTemplate += Application_CustomizeTemplate;
    }
    void Application_CustomizeTemplate(object sender, CustomizeTemplateEventArgs e) {
        if (e.Context == TemplateContext.NestedFrame) {
            ISupportActionsToolbarVisibility template = 
                e.Template as ISupportActionsToolbarVisibility;
            if (template != null) template.SetVisible(false);
        }
    }
    protected override void OnDeactivated() {
        Application.CustomizeTemplate -= Application_CustomizeTemplate;
        base.OnDeactivated();
    }
}

To learn how to customize a template in an ASP.NET application, refer to the How to: Customize an ASP.NET Template topic.

See Also