ViewController<ViewType> Class
A base class for generic View Controllers.
Namespace: DevExpress.ExpressApp
Assembly: DevExpress.ExpressApp.v24.2.dll
NuGet Package: DevExpress.ExpressApp
Declaration
Type Parameters
Name |
---|
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
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.
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 {
//...
}