Skip to main content
All docs
V24.1
.NET 6.0+

XAF0021: Create new controllers correctly

Severity: Warning

Avoid creating a DialogController with a parameterless constructor, otherwise, the dialog will not be localized.

Use Application.CreateController<DialogController>() instead. You can also use PopupWindowShowAction or Application.ShowViewStrategy.ShowViewInPopupWindow to display a dialog window.

Examples

Invalid Code

using DevExpress.ExpressApp.SystemModule;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp;
using DevExpress.Xpo;

namespace TestApplication.Module.PlatformSpecificModulesTest {
    public class MyBusinessClass : BaseObject { }

    public class TestClass {
        public XafApplication Application { get; set; }

        void myAction_Execute(object sender, SimpleActionExecuteEventArgs e) {
            e.ShowViewParameters.CreatedView = 
                Application.CreateListView(typeof(MyBusinessClass), true);
            e.ShowViewParameters.TargetWindow = TargetWindow.NewWindow;
            // Do not instantiate a dialog controller with a parameterless constructor
            e.ShowViewParameters.Controllers.Add(new DialogController()); // Warning
        }
    }
}

Valid Code

using DevExpress.ExpressApp.SystemModule;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp;
using DevExpress.Xpo;

namespace TestApplication.Module.PlatformSpecificModulesTest {
    public class MyBusinessClass : BaseObject { }
    public class TestClass {
        public XafApplication Application { get; set; }

        void myAction_Execute(object sender, SimpleActionExecuteEventArgs e) {
            e.ShowViewParameters.CreatedView = 
                Application.CreateListView(typeof(MyBusinessClass), true);
            e.ShowViewParameters.TargetWindow = TargetWindow.NewWindow;
            // This code meets the requirements
            e.ShowViewParameters.Controllers.Add(Application.CreateController<DialogController>());
        }
    }
}