Skip to main content
All docs
V24.2
.NET 8.0+

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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>());
        }
    }
}