ShowViewParameters.Controllers Property
A collection of Controllers that should be activated for the target View or its Window.
Namespace: DevExpress.ExpressApp
Assembly: DevExpress.ExpressApp.v25.2.dll
NuGet Package: DevExpress.ExpressApp
Declaration
Property Value
| Type | Description |
|---|---|
| List<Controller> | A collection of Controllers. |
Remarks
When you display a View, the following Controllers are created:
- All Controllers from the Application Model that relate to your View or its Window. You can use the CreateAllControllers option to disable this behavior.
- Controllers specified in the
Controllerscollection.
Use the Controllers property to create Controllers for the Frame or Window. You can also replace the default Controllers.
Your Controllers are active only if constraints like TargetViewType or TargetObjectType match. These constraints apply to your Controller’s Actions as well. The Action Containers that display these Actions must exist in the Template for the target Window. Set the correct ActionBase.Category property for each Action.
Note
Deactivate your Controllers when they are not needed. Use Controller.Active for this purpose.
The following code sample adds DialogController to the Controllers collection. This controller is intended for use in popup Windows and you should manually add it to a popup Window’s Controllers.
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>());
}
If you invoke a popup Window with PopupWindowShowAction, the system automatically adds DialogController. You can use the CustomizePopupWindowParamsEventArgs.DialogController parameter to replace it with your custom Controller.
Note
If you display the target View in the current Window (Frame), the system does not add Controllers to that Window (Frame).