XafApplication.OptimizedControllersCreation Property
Disables the instantiation of Controllers that will never be activated in nested List Views.
Namespace: DevExpress.ExpressApp
Assembly: DevExpress.ExpressApp.v21.2.dll
NuGet Package: DevExpress.ExpressApp
Declaration
Property Value
Type | Default | Description |
---|---|---|
Boolean | false | true, if the optimized controllers creation is enabled; otherwise, false. |
Remarks
When the OptimizedControllersCreation property is set to true, View Controllers that won’t be activated due to ViewController.TargetViewType, ViewController.TargetViewNesting, ViewController.TargetObjectType or ViewController.TargetViewIdrestrictions are not created.
This optimization is supported in Windows and Frames, whose Frame.View is not changed during the Frame life cycle:
Popup Windows - Windows, created using the following approaches:
- by executing an Action with the ShowViewParameters.TargetWindow set to NewWindow or NewModalWindow (the ShowViewParameters object is passed to the ActionBaseEventArgs.ShowViewParameters argument of the Action’s Execute event);
- by executing an Action with the ShowViewParameters.TargetWindow set to Default in a WinForms application with MDI IModelOptionsWin.UIType or in an ASP.NET Web Forms application with the IModelOptionsWeb.CollectionsEditMode value set to Edit.
- by calling the ShowViewStrategyBase.ShowViewInPopupWindow method directly.
Nested Frames - Frames created within the following Property Editors and View Items:
- ListPropertyEditor (see Collection Properties);
- DetailPropertyEditor, LookupPropertyEditor and ASPxLookupPropertyEditor (see Reference Properties);
- ObjectPropertyEditor (see Reference (Foreign Key, Complex Type) Properties);
- DashboardViewItem (see How to: Display Several Views Side-by-Side).
If you have a custom Action which changes the Frame’s View (e.g, by setting TargetWindow to Current) in one of the aforementioned cases, set OptimizedControllersCreation to false.
The OptimizedControllersCreation value has no effect when the Frame’s View can be changed (e.g., when the Frame is the application’s main window). In this case, all Frame’s Controllers are instantiated preliminarily.
In applications created using the Solution Wizard version 17.1 or higher, the OptimizedControllersCreation property is set to true by default. It is recommended to set it to true in applications that are created in older versions. This can be done in the WinApplication and WebApplication descendant’s constructors:
public partial class MainDemoWinApplication : WinApplication {
public MainDemoWinApplication() {
InitializeComponent();
this.OptimizedControllersCreation = true;
}
// ...
}
Important
To avoid possible null reference exceptions when accessing an existing Controller from your code, always ensure that the Frame.GetController<ControllerType> method result is not null when the XafApplication.OptimizedControllersCreation
property is true.