Back to Devexpress

ViewController<ViewType> Class

expressappframework-devexpress-dot-expressapp-dot-viewcontroller-1.md

latest6.6 KB
Original Source

ViewController<ViewType> Class

A base class for generic View Controllers.

Namespace : DevExpress.ExpressApp

Assembly : DevExpress.ExpressApp.v25.2.dll

NuGet Package : DevExpress.ExpressApp

Declaration

csharp
public abstract class ViewController<ViewType> :
    ViewController
    where ViewType : View
vb
Public MustInherit Class ViewController(Of ViewType As View)
    Inherits ViewController

Type Parameters

NameDescription
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.

csharp
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.

csharp
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 {
    //...
}

Implements

ISupportUpdate

Inheritance

Show 26 items

Object MarshalByRefObject Component Controller ViewController ViewController<ViewType> CloseDetailViewController

ListEditorInplaceEditController

ObjectViewController

ObjectViewController<ViewType, ObjectType>

WinGridReportExportController

WinReportsController

ModificationsController

ProcessDataLockingInfoController

BlazorModificationsController

AppearanceController

CloneObjectViewController

WorkingModeSwitchController

BlazorHideDetailViewNewActionController

BlazorHideRefreshActionController

DashboardConfirmationUnsavedChangesController

ExportToXmlController

HasRightsToModifyMemberController

WinModificationsController

PrintSelectionBaseController

ReportsControllerCore

See Also

ViewController<ViewType> Members

DevExpress.ExpressApp Namespace