Skip to main content
.NET 6.0+

ShowViewParameters.Controllers Property

Provides access to a collection of Controllers that should only be activated for the target View or its Window.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v24.1.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public List<Controller> Controllers { get; }

Property Value

Type Description
List<Controller>

A List<Controller> object that represents a collection of Controllers to be activated for the target View or its Window.

Remarks

When a Frame (Window) is created, all the Controllers that are registered in the Application Model are instantiated. At some point, they are activated if they are appropriate in the current context. Use the Controllers property to create a Controller that is specific for the created frame (window). You can add an instance of any Controller. Your instance will replace the corresponding automatically created instance. Note that your instance will be activated if all the constraints like ViewController.TargetViewType or ViewController.TargetObjectType are satisfied. The same relates to your Controller’s Actions. In addition, the Action Containers that will display these Actions must be contained in the Template that shows the target Window (see ShowViewParameters.Context). So, you need to specify the appropriate value for the ActionBase.Category property for these Actions.

Note

Since your Controllers are intended for a particular View only, do not forget to deactivate them in all the remaining scenarios. For example, use the Controller.Active method.

An example of a Controller that can be added to the Controllers collection is an instance of the DialogController class or its descendant. The DialogController is not activated anywhere except for pop-up Windows. Moreover, you should manually add it to a pop-up Window via the Controllers property. The following code demonstrates this:

using DevExpress.ExpressApp.SystemModule;
// ...
void myAction_Execute(Object sender, SimpleActionExecuteEventArgs e) {
   IObjectSpace objectSpace = Application.CreateObjectSpace(typeof(MyBusinessClass));
   string listViewId = Application.FindListViewId(typeof(MyBusinessClass));
   e.ShowViewParameters.CreatedView = Application.CreateListView(
      listViewId,
      Application.CreateCollectionSource(objectSpace,typeof(MyBusinessClass),listViewId),
      true);
   e.ShowViewParameters.TargetWindow = TargetWindow.NewWindow;
   e.ShowViewParameters.Controllers.Add(Application.CreateController<DialogController>());
}

In pop-up Windows that are invoked when executing a PopupWindowShowAction, the Dialog Controller is added by default. You do not need to add it manually. However, you can replace it with a custom one via the Execute event handler’s CustomizePopupWindowParamsEventArgs.DialogController parameter.

Note

Controllers that are passed via the Controllers parameter are not added to the Frame when a created View is shown in the current window (i.e., the ShowViewParameters.TargetWindow parameter is set to TargetWindow.Current).

To cancel activation of all the Controllers from the Application Model that can be activated for the target View or its Window, set the ShowViewParameters.CreateAllControllers property to false. In this case, if you want their Actions’ buttons to be created in a Template, add the FillActionContainersController to the Controllers collection.

See Also