XafApplication.OptimizedControllersCreation Property
Disables the instantiation of Controllers that will never be activated in nested List Views.
Namespace: DevExpress.ExpressApp
Assembly: DevExpress.ExpressApp.v24.1.dll
NuGet Package: DevExpress.ExpressApp
#Declaration
#Property Value
Type | Default | Description |
---|---|---|
Boolean | false |
|
#Remarks
In applications created using the Solution Wizard version 17.1 or higher, the default OptimizedControllersCreation
property value is true
. This happens because the wizard generates new projects with the FrameworkSettings.DefaultSettingsCompatibilityMode property set to Latest
.
When the OptimizedControllersCreation
property is set to true
, View Controllers that are not activated due to ViewController.TargetViewType, ViewController.TargetViewNesting, ViewController.TargetObjectType, or ViewController.TargetViewId restrictions, are not created.
This optimization is supported in Windows and Frames, whose Frame.View does not change during the Frame’s life cycle:
Popup Windows – Windows created using the following approaches:
- By an Action with the ShowViewParameters.TargetWindow set to
NewWindow
orNewModalWindow
(the ShowViewParameters object is passed to the ActionBaseEventArgs.ShowViewParameters argument of the Action’sExecute
event); - By the ellipsis button of an ObjectPropertyEditor (see Reference (Foreign Key, Complex Type) Properties);
- By showing Detail Views of objects from aggregated collection properties (in WinForms and ASP.NET Core Blazor) or nested List Views in Edit mode (in ASP.NET Web Forms);
- By the ShowViewStrategyBase.ShowViewInPopupWindow method directly.
- By an Action with the ShowViewParameters.TargetWindow set to
Nested Frames – Frames created within the following Property Editors and View Items:
- ListPropertyEditor (see Collection Properties);
- DetailPropertyEditor, LookupPropertyEditor, and ASPxLookupPropertyEditor (see Reference Properties);
- DashboardViewItem (see How to: Display Several Views Side-by-Side).
MDI Tabs – Windows shown as tabs within the main window with IModelOptionsBlazor.UIType (ASP.NET Core Blazor) and IModelOptionsWin.UIType (Windows Forms) set to
TabbedMDI
.
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 (for example, when the Frame is the application’s main window). In this case, the application creates instances of all registered Controller types for this Frame beforehand.
Important
To avoid possible null reference exceptions when accessing an existing Controller from your code, always ensure that the Frame.Xaf
property is true.