Back to Devexpress

ObjectViewController<ViewType, ObjectType> Class

expressappframework-devexpress-dot-expressapp-dot-objectviewcontroller-2.md

latest5.5 KB
Original Source

ObjectViewController<ViewType, ObjectType> Class

A base class for View Controllers intended for Object Views.

Namespace : DevExpress.ExpressApp

Assembly : DevExpress.ExpressApp.v25.2.dll

NuGet Package : DevExpress.ExpressApp

Declaration

csharp
public abstract class ObjectViewController<ViewType, ObjectType> :
    ViewController<ViewType>
    where ViewType : ObjectView
vb
Public MustInherit Class ObjectViewController(Of ViewType As ObjectView, ObjectType)
    Inherits ViewController(Of ViewType)

Type Parameters

NameDescription
ViewType

Specifies the ViewController.TargetViewType value.

| | ObjectType |

Specifies the ViewController.TargetObjectType value

|

Remarks

This Controller inherist from the ObjectViewController and introduces two generic type parameters:

ParameterDescription
ViewTypeSpecifies the ViewController.TargetViewType value.
ObjectTypeSpecifies the ViewController.TargetObjectType value.

Use this class as the base class for a custom Controller to ensure that the custom Controller is activated for a specific View type and Object type.

The following code snippet demonstrates a custom View Controller derived from the generic ObjectViewController.

csharp
using DevExpress.Blazor;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Blazor.Editors;
using MainDemo.Module.BusinessObjects;

namespace MainDemo.Blazor.Server.Controllers;

public sealed class ContactListViewController : ObjectViewController<ListView, Contact> {
    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 cannot be used with generic components, so you cannot use it to design generic Controllers. As a possible workaround, you can declare an intermediate non-generic base class, derived from a generic Controller and decorated with the DesignerCategoryAttribute, and then derive your custom Controller from this intermediate class. The following code snippet illustrates this.

csharp
using System.ComponentModel;
using DevExpress.Blazor;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Blazor.Editors;
using MainDemo.Module.BusinessObjects;

namespace MainDemo.Blazor.Server.Controllers;

public abstract class MyIntermediateListViewController : ObjectViewController<ListView, Contact> {
    // ...
}

public sealed class MyViewController : MyIntermediateListViewController {
    // ...
}

Implements

ISupportUpdate

Inheritance

Show 14 items

Object MarshalByRefObject Component Controller ViewController ViewController<ViewType> ObjectViewController<ViewType, ObjectType> BlazorHideRefreshActionController

DashboardConfirmationUnsavedChangesController

ExportToXmlController

WorkingModeSwitchController

WinReportsController

BlazorHideDetailViewNewActionController

ReportsControllerCore

See Also

ObjectViewController<ViewType, ObjectType> Members

DevExpress.ExpressApp Namespace