Skip to main content
.NET Standard 2.0+

Controller Class

The base class for Controllers.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v23.1.dll

NuGet Package: DevExpress.ExpressApp


public abstract class Controller :


Use Controllers to change your application’s flow or implement custom user interaction. Custom code in a Controller is executed when XAF creates a Window or Frame for this Controller.

Controllers also serve as containers for Actions.

Controllers in XAF support dependency injection in .NET 6+ ASP.NET Core Blazor and Windows Forms applications.

To implement a Controller, inherit from the Controller class or one of its descendants, such as:

Used to implement custom features in nested or root Views
Used to implement custom features in Windows.

Visual Studio Controller Template

To create a Controller with a Visual Studio template, right-click the Controllers folder in your XAF project and select Add DevExpress Item | New Item…. In the navigation pane of the invoked Template Gallery, choose XAF Controllers | View Controller or XAF Controllers | Window Controller.


CodeRush allows you to add Actions and Controllers with a few keystrokes. To learn about the Code Templates for XAF, refer to the following help topic: XAF Templates.

Built-in Controller Customization

XAF supplies built-in Controllers to perform basic functions in ASP.NET Core Blazor, Windows Forms, and ASP.NET Web Forms applications. To customize the behavior of a particular Controller in code, inherit from it or subscribe to its events. For additional information, refer to the following topics:

XAF automatically instantiates public Controllers with public parameterless constructors.

Custom Code in Controllers

To provide custom code that XAF performs at runtime, use Controller’s activation and deactivation mechanisms.

To activate or deactivate a Controller, use the Controller.Active property.

To determine the current state of a Controller, use the Controller.Active property in a conditional expression. Alternatively, use the BoolList.ResultValue property of the object that the Controller.Active property returns.

To provide custom code that XAF executes each time a Controller is activated or deactivated, handle the Controller.Activated and Controller.Deactivated events or override the OnActivated and OnDeactivated methods.

To access a Controller’s Action collection in code, use the Controller.Actions property.


See Also