Skip to main content
All docs
V22.2

XAF Templates

  • 8 minutes to read

This topic describes templates you can use when you implement Controllers and Actions in eXpressApp Framework (XAF).

Important

Visual Studio IntelliSense has priority over CodeRush templates. For information on how to prioritize a CodeRush template over Visual Studio IntelliSense, refer to the following topic section: Expand a Template Instead of Visual Studio IntelliSense.

XAF Custom Controllers

ViewController

Template: xcv

public class MyViewController : ViewController
{
    public MyViewController() : base()
    {
        // Target required Views (use the TargetXXX properties) and create their Actions.

    }
    protected override void OnActivated()
    {
        base.OnActivated();
        // Perform various tasks depending on the target View.
    }
    protected override void OnDeactivated()
    {
        // Unsubscribe from previously subscribed events and release other references and resources.
        base.OnDeactivated();
    }
    protected override void OnViewControlsCreated()
    {
        base.OnViewControlsCreated();
        // Access and customize the target View control.
    }
}

WindowController

Template: xcw

public class MyWindowController : WindowController
{
    public MyWindowController() : base()
    {
        // Target required Windows (use the TargetXXX properties) and create their Actions.

    }
    protected override void OnActivated()
    {
        base.OnActivated();
        // Perform various tasks depending on the target Window.
    }
    protected override void OnDeactivated()
    {
        // Unsubscribe from previously subscribed events and release other references and resources.
        base.OnDeactivated();
    }
}

ObjectViewController for DetailView

Template: xcvod

public class MyDetailViewController : ObjectViewController<DetailView, BusinessObject>
{
    public MyDetailViewController() : base()
    {
        // Target required Views (use the TargetXXX properties) and create their Actions.

    }
    protected override void OnActivated()
    {
        base.OnActivated();
        // Perform various tasks depending on the target View.
    }
    protected override void OnDeactivated()
    {
        // Unsubscribe from previously subscribed events and release other references and resources.
        base.OnDeactivated();
    }
    protected override void OnViewControlsCreated()
    {
        base.OnViewControlsCreated();
        // Access and customize the target View control.
    }
}

ObjectViewController for ListView

Template: xcvol

public class MyListViewController : ObjectViewController<ListView, BusinessObject>
{
    public MyListViewController() : base()
    {
        // Target required Views (use the TargetXXX properties) and create their Actions.

    }
    protected override void OnActivated()
    {
        base.OnActivated();
        // Perform various tasks depending on the target View.
    }
    protected override void OnDeactivated()
    {
        // Unsubscribe from previously subscribed events and release other references and resources.
        base.OnDeactivated();
    }
    protected override void OnViewControlsCreated()
    {
        base.OnViewControlsCreated();
        // Access and customize the target View control.
    }
}

ViewController for DetailView

Template: xcvd

public class MyDetailViewController : ViewController<DetailView>
{
    public MyDetailViewController() : base()
    {
        // Target required Views (use the TargetXXX properties) and create their Actions.

    }
    protected override void OnActivated()
    {
        base.OnActivated();
        // Perform various tasks depending on the target View.
    }
    protected override void OnDeactivated()
    {
        // Unsubscribe from previously subscribed events and release other references and resources.
        base.OnDeactivated();
    }
    protected override void OnViewControlsCreated()
    {
        base.OnViewControlsCreated();
        // Access and customize the target View control.
    }
}

ViewController for ListView

Template: xcvl

public class MyListViewController : ViewController<ListView>
{
    public MyListViewController() : base()
    {
        // Target required Views (use the TargetXXX properties) and create their Actions.

    }
    protected override void OnActivated()
    {
        base.OnActivated();
        // Perform various tasks depending on the target View.
    }
    protected override void OnDeactivated()
    {
        // Unsubscribe from previously subscribed events and release other references and resources.
        base.OnDeactivated();
    }
    protected override void OnViewControlsCreated()
    {
        base.OnViewControlsCreated();
        // Access and customize the target View control.
    }
}

XAF Actions

XAF templates that create Actions are available when the caret is inside a custom controller’s method.

SimpleAction

Template: xas

public class MyViewController : ViewController
{
    SimpleAction action;
    public MyViewController() : base()
    {
        // Target required Views (use the TargetXXX properties) and create their Actions.
        action = new SimpleAction(this, "MyAction", "View");
        action.Execute += action_Execute;

    }
    private void action_Execute(object sender, SimpleActionExecuteEventArgs e)
    {
        // Execute your business logic (https://docs.devexpress.com/eXpressAppFramework/112737/).
    }
    //...
}

SingleChoiceAction

Template: xac

public class MyViewController : ViewController
{
    SingleChoiceAction action;
    public MyViewController() : base()
    {
        // Target required Views (use the TargetXXX properties) and create their Actions.
        action = new SingleChoiceAction(this, "MyAction", "View");
        action.ItemType = SingleChoiceActionItemType.ItemIsOperation;
        action.Execute += action_Execute;
        // Create some items
        //action.Items.Add(new ChoiceActionItem("MyItem1", "My Item 1", 1));     
    }
    private void action_Execute(object sender, SingleChoiceActionExecuteEventArgs e)
    {
        var itemData = e.SelectedChoiceActionItem.Data;
        // Execute your business logic (https://docs.devexpress.com/eXpressAppFramework/112738/).
    }
    //...
}

ParametrizedAction

Template: xap

public class MyViewController : ViewController
{
    ParametrizedAction action;
    public MyViewController() : base()
    {
        // Target required Views (use the TargetXXX properties) and create their Actions.
        action = new ParametrizedAction(this, "MyAction", "View", typeof(string));
        action.Execute += action_Execute;

    }
    private void action_Execute(object sender, ParametrizedActionExecuteEventArgs e)
    {
        var parameterValue = (string)e.ParameterCurrentValue;
        // Execute your business logic (https://docs.devexpress.com/eXpressAppFramework/112724/).
    }
    //...
}

PopupWindowShowAction

Template: xapw

public class MyViewController : ViewController
{
    PopupWindowShowAction action;
    public MyViewController() : base()
    {
        // Target required Views (use the TargetXXX properties) and create their Actions.
        action = new PopupWindowShowAction(this, "MyAction", "View");
        action.Execute += action_Execute;
        action.CustomizePopupWindowParams += action_CustomizePopupWindowParams;

    }
    private void action_Execute(object sender, PopupWindowShowActionExecuteEventArgs e)
    {
        var selectedPopupWindowObjects = e.PopupWindowViewSelectedObjects;
        var selectedSourceViewObjects = e.SelectedObjects;
        // Execute your business logic (https://docs.devexpress.com/eXpressAppFramework/112723/).
    }
    private void action_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs e)
    {
        // Set the e.View parameter to a newly created view (https://docs.devexpress.com/eXpressAppFramework/112723/).
    }
    //...
}
See Also