Controller Class

The base class for Controllers.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v18.2.dll


public abstract class Controller :
Public MustInherit Class Controller
    Inherits Component
    Implements ISupportUpdate


Controllers are used to customize the program flow or implement end-user interaction. Controllers can execute custom code when their owner, Window or Frame, is created. They also serve as containers for Actions.

To implement a Controller, you should inherit from the Controller class or one of its descendants. Usually, the following Controller class descendants are used as ancestors for new Controllers: ViewController and WindowController. The ViewController class is used to implement custom features with Views (whether nested or root), the WindowController class - with Windows.

There is a Visual Studio template for controller creation. Right-click the Controllers folder of an XAF project and select Add DevExpress Item | New Item... to invoke Template Gallery. Then choose XAF Controllers | View Controller or XAF Controllers | Window Controller.

The eXpressApp Framework supplies a great many built-in Controllers to perform basic features in Windows Forms applications and Web Sites. If you need to customize the behavior of a particular Controller, inherit from it or subscribe to its events. To learn more, refer to the Controllers and Customize Controllers and Actions topics.

You can customize Controllers using the IModelControllers node in the Model Editor. Information on Controllers is represented by properties of the ActionDesign | Controllers | Controller nodes. These properties can be initially set to default values or the values that you specified in the Controller's constructor, or in the Controller's Designer. You can modify these values if the properties are not read-only.

You do not need to create Controllers, because all the Controllers defined in the Application Model are created automatically.

To provide custom code that will be performed at runtime, use the Controller activation and deactivation mechanisms. Use the Controller.Active property to activate and deactivate a Controller. Handle the Controller.Activated and Controller.Deactivated events, to provide custom code to be executed each time a Controller is activated or deactivated. To determine the current active state of a Controller, use the Controller.Active property in a conditional expression. Alternatively, use the BoolList.ResultValue property of the object returned by the Controller.Active property.

To add an Action to a Controller, use the Designer. To access a Controller's Action collection in code, use the Controller.Actions property.

See Also