Back to Devexpress

XafApplication.CreateController<ControllerType>() Method

expressappframework-devexpress-dot-expressapp-dot-xafapplication-dot-createcontroller-1.md

latest4.7 KB
Original Source

XafApplication.CreateController<ControllerType>() Method

Creates a Controller of a specified type. If there is a Controller of the same type, assigns its settings to the new Controller.

Namespace : DevExpress.ExpressApp

Assembly : DevExpress.ExpressApp.v25.2.dll

NuGet Package : DevExpress.ExpressApp

Declaration

csharp
public virtual ControllerType CreateController<ControllerType>()
    where ControllerType : Controller, new()
vb
Public Overridable Function CreateController(Of ControllerType As {Controller, New}) As ControllerType

Type Parameters

Name
ControllerType

Returns

TypeDescription
ControllerType

A Controller of the specified type.

|

Remarks

When you implement a PopupWindowShowAction, you may need to provide a custom Dialog Controller for the Action’s pop-up Window. Use the CreateController<ControllerType> method to create this custom Dialog Controller:

csharp
private void MyPopupWindowShowAction_OnCustomizePopupWindowParams(Object sender,
      CustomizePopupWindowParamsEventArgs e) {
   //...
   e.DialogController = Application.CreateController<MyDialogController>();
}

This method creates a Controller of the specified type. If a Controller of the same type already exists, the Controller.Actions of the found Controller serve as a source for the ActionBase.Model property of the new Controller’s Actions.

The following code snippets (auto-collected from DevExpress Examples) contain references to the CreateController<ControllerType>() method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

XAF_logon-form-manage-users-register-a-new-user-restore-a-password/CS/Security.Extensions/Module.cs#L28

csharp
var application = (XafApplication)sender;
e.Controllers.Add(application.CreateController<ManageUsersOnLogonController>());
e.Controllers.Add(application.CreateController<LogonActionCustomizationController>());

xaf-how-to-save-the-currently-opened-view-as-a-new-view-variant-at-runtime/CS/EF/ViewVariantSaveEF/ViewVariantSaveEF.Module/Controllers/UserViewVariantsController.cs#L114

csharp
}
DialogController dialogController = Application.CreateController<DialogController>();
dialogController.Accepting += dialogController_Accepting;

XAF_how-to-show-filter-dialog-before-listview/CS/EFCore/DialogBeforeListViewEF/DialogBeforeListViewEF.Win/Controllers/WinShowFilterDialogController.cs#L48

csharp
e.ActionArguments.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow;
DialogController dialogCotnroller = Application.CreateController<DialogController>();
dialogCotnroller.Accepting += new EventHandler<DialogControllerAcceptingEventArgs>(dialogCotnroller_Accepting);

See Also

XafApplication Class

XafApplication Members

DevExpress.ExpressApp Namespace