The requested page is not available for the requested platform. You are viewing the content for Default platform.

ViewController<ViewType> Class

A base class for generic View Controllers.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v19.1.dll

Declaration

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

Type Parameters

Name Description
ViewType

Remarks

This is a generic version of the ViewController class. The generic type parameter specifies the View type for which the Controller is intended. There are several differences between the non-generic and generic ViewControllers. First, the type specified by the generic type parameter is assigned to the ViewController.TypeOfView property, so that the Controller is only activated for this View type. Second, the type of the ViewController.View property is changed to the type specified by the generic type parameter, so that you do not need to perform an additional cast, when accessing the View.

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

public class MyViewController : ViewController<ListView> {
    protected override void OnViewControlsCreated() {
        base.OnViewControlsCreated();
        // The View property is of the ListView type
        ASPxGridListEditor listEditor = View.Editor as ASPxGridListEditor;
        if (listEditor != null) {
            // Perform some actions here
            // ...
        }
    }
}

Note that 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.

[System.ComponentModel.DesignerCategory("Component")]
public class MyIntermediateListViewController : ViewController<ListView> { }

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

Implements

See Also