Suppose that it is necessary to provide a capability to work with documents. These documents can have various sets of fields, in various orders. To implement this scenario using standard XAF tools, it is necessary to create a lot of business classes, one for each kind of document. This solution doesn't allow the creation of a new document kind.
How to add custom properties to a DetailView dynamically at runtime
Answers approved by DevExpress Support
You can accomplish this task by embedding a custom control that renders the required editors based on a collection of custom properties:
How to: Show a Custom Data-Bound Control in an XAF View (Blazor) - Current Object Data
How to: Show a Custom Data-Bound Control in an XAF View (WinForms)
How to: Show a Custom Data-Bound Control in an XAF View (ASP.NET)
Obsolete
Attached is an example that demonstrates how to implement a custom property editor named DocumentItemsPropertyEditor. It is used to draw a table with editors associated with document items.
We consider this approach as outdated and advise against using it in a new project. If you used this approach for the long time and found that ASPxLookupPropetyEditor throws NullReferenceException when closing a DetailView, download the modified example attached to this answer and replace the WebDocumentItemsPropertyEditor.cs or WebDocumentItemsPropertyEditor.vb file in your project with the new version.
See Also:
How to: Include a Custom UI Control That Is Not Integrated by Default (WinForms, ASP.NET WebForms, and ASP.NET Core Blazor)
How to create business classes at runtime based on predefined configurations or allow user to define custom members via the application UI
Does not work in edit mode on v12.1.4
This example fails on 'New'. Run, click new button.
NullReferenceExeption: Object reference not set to an instance of an object.
private void CreateLayoutItems(LayoutControl layout) {
…
for (int i = 0; i < itemsPerRow - columnIndex; i++) {
FAIL --> row.Add(new EmptySpaceItem());
}
I have fixed the problem. Please see the updated example.