What Changed
In v24.1+, the ViewItem.Control and ListEditor.Control properties of all built-in List Editors, View Items, and Property editors return a corresponding Component Model instead of an Adapter.
For example:
DxGridListEditor.Control
returns GridModel instead of DxGridAdapterDateTimePropertyEditor.Control
returnsDxDateEditModel
instead ofDxDateEditAdapter
ReportDesignerViewItem.Control
returnsDxReportDesignerModel
instead ofDxReportDesignerAdapter
Reasons for Change
This change aims to improve user experience with XAF Blazor and make it more in line with other platforms (ASP.NET Web Forms and Windows Forms). User feedback indicated that interaction with List and Property Editors in XAF Blazor was more challenging compared to other platforms. Removal of Adapters allows customers to interact with Component Models directly.
Impact on Existing Apps
This change affects the Control
return type of all built-in List Editors, View Items, and Property Editors.
How to Update Existing Apps
To update existing applications, refactor code that accesses List/Property Editor's Adapter instances and use the corresponding Component Model classes instead. For example:
List Editor:
C#protected override void OnViewControlsCreated() {
base.OnViewControlsCreated();
//Before
if(View.Editor is DxGridListEditor gridListEditor && gridListEditor.Control is IDxGridAdapter adapter) {
adapter.GridModel.PagerVisible = false;
adapter.GridDataColumnModels.First(c => c.FieldName == "FirstName").AllowSort = false;
}
//Now
if(View.Editor is DxGridListEditor gridListEditor) {
gridListEditor.GridModel.PagerVisible = false;
gridListEditor.GridDataColumnModels.First(c => c.FieldName == "FirstName").AllowSort = false;
}
}
Property Editor:
C#protected override void OnActivated() {
base.OnActivated();
//Before
View.CustomizeViewItemControl<DateTimePropertyEditor>(this, (propertyEditor) => {
if(propertyEditor.Control is DxDateEditAdapter adapter) {
adapter.ComponentModel.DropDownVisible = false;
}
});
//Now
View.CustomizeViewItemControl<DateTimePropertyEditor>(this, (propertyEditor) => {
propertyEditor.ComponentModel.DropDownVisible = false;
});
}
Adapter-Based Approach in Custom Property Editors
The adapter-based approach remains applicable. However, ensure that any class that inherits from ComponentAdapterBase
overrides the ComponentModel
property and returns a non-null value.
C#public class InputAdapter : ComponentAdapterBase {
public InputAdapter(InputModel componentModel) {
ComponentModel = componentModel;
}
// ...
public override InputModel ComponentModel { get; }
}
How to Revert to Previous Behavior
In the SolutionName.Blazor.Server/Program.cs file of your ASP.NET Core Blazor application project, set FrameworkSettings.DefaultSettingsCompatibilityMode to the previous version or set the DevExpress.ExpressApp.Blazor.BlazorApplication.UseComponentModel
property value to false
:
C#public static int Main(string[] args) {
DevExpress.ExpressApp.FrameworkSettings.DefaultSettingsCompatibilityMode = DevExpress.ExpressApp.FrameworkSettingsCompatibilityMode.v23_2;
// or
DevExpress.ExpressApp.Blazor.BlazorApplication.UseComponentModel = false;
}