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

Frame.GetController<ControllerType>() Method

Returns a specified Controller from the current Frame's Frame.Controllers collection.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v19.1.dll


public ControllerType GetController<ControllerType>()
    where ControllerType : Controller
Public Function GetController(Of ControllerType As Controller) As ControllerType


Type Description

A specified Controller found in the current Frame's Frame.Controllers collection.

Type Parameters

Name Description


Use the GetController<ControllerType> method to access a particular Controller from the current Frame's Frame.Controllers collection. The ControllerType generic type argument specifies the required Controller type. In this argument, you can specify any class which is a descendant of the Controller class.

The code below demonstrates how to access the NewObjectViewController and add its NewObjectAction to the Quick Access Toolbar.

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.SystemModule;

// ...
public class NewObjectActionController : WindowController {
    protected override void OnActivated() {
        NewObjectViewController newObjectViewController = Window.GetController<NewObjectViewController>();
        if(newObjectViewController != null) {
            newObjectViewController.NewObjectAction.QuickAccess = true;

If there is no Controller of the specified type in the Frame.Controllers collection, this method returns the first Controller which is assignable to this type.


To avoid possible null reference exceptions when accessing an existing Controller from your code, always ensure that the Frame.GetController<ControllerType> method result is not null when the XafApplication.OptimizedControllersCreation property is true.

See Also