ViewController<ViewType> Class
A base class for generic View Controllers.
Namespace: DevExpress.ExpressApp
Assembly: DevExpress.ExpressApp.v25.2.dll
NuGet Package: DevExpress.ExpressApp
Declaration
Type Parameters
| Name | Description |
|---|---|
| ViewType | The XAF View subtype (for example, DetailView, ListView, or DashboardView) that this Controller targets. |
Remarks
ViewController<ViewType> is the generic version of the ViewController class. The ViewType type parameter specifies the View subtype that the Controller targets. XAF assigns ViewType to the ViewController.TypeOfView property, so the Controller is activated only for that View type. The ViewController.View property is typed as ViewType, so you can access the View without an explicit cast.
The following code snippet demonstrates a custom View Controller derived from the generic ViewController.
using DevExpress.Blazor;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Blazor.Editors;
using MainDemo.Module.BusinessObjects;
namespace MainDemo.Blazor.Server.Controllers;
public sealed class EmlployeeListViewController : ObjectViewController<ListView, Employee> {
protected override void OnViewControlsCreated() {
base.OnViewControlsCreated();
if(View.Editor is DxGridListEditor gridListEditor) {
// ...
}
}
}
Note
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.
Visual Studio Designer does not support generic components and cannot be used to design generic Controllers. As a workaround, declare an intermediate non-generic base class that derives from a generic Controller and is decorated with the DesignerCategoryAttribute. Then derive your custom Controller from that intermediate class. The following code snippet illustrates this approach.
using System.ComponentModel;
using DevExpress.Blazor;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Blazor.Editors;
using MainDemo.Module.BusinessObjects;
namespace MainDemo.Blazor.Server.Controllers;
[DesignerCategory("Component")]
public abstract class MyIntermediateListViewController : ObjectViewController<ListView, Employee> {
//...
}
public sealed class MyViewController : MyIntermediateListViewController {
//...
}