expressappframework-404700-ui-construction-view-items-and-property-editors-how-to-show-a-custom-data-bound-control-in-an-xaf-view-how-to-show-a-custom-data-bound-control-in-an-xaf-blazor-advanced.md
This article explains how to create a reusable View Item that uses data from the View’s current object. Before starting, review the Read Tutorial: How to: Show a Custom Data-Bound Control in an XAF View (Blazor) - External Data tutorial on the basic steps.
In this example, you create a Razor component based on DxAccordion. The new component displays employees assigned to a particular department.
To add this component to your project, follow the steps below:
In the Solution Explorer , right-click your project’s name and select Add | New Item… from the context menu.
Specify a component name (DepartmentViewer.razor).
Add the following code to the created file.
In the Properties window, set this file’s Build Action to Content.
Rebuild your solution.
The component in this example uses the CascadingParameter of DevExpress.ExpressApp.Blazor.Editors.BlazorControlViewItem to access an ObjectSpace instance. It uses the Object Space API to read the required data and then initialize the data source or refresh the data if necessary.
In the Blazor application project, double-click the Model.xafml file to start the Model Editor. Right-click the Views node and choose Add… | DetailView.
Set the Id property to CustomDepartment_DetailView and the ModelClass property to MainDemo.Module.BusinessObjects.Department.
Right-click the Views | MainDemo.Module.BusinessObjects | Department | CustomDepartment_DetailView | Items node and choose Add… | ControlDetailItem.
Set the Id property to DepartmentViewItem and the IModelControlDetailItem.ControlTypeName property to the type of the Razor Component you created (for example, MainDemo.Blazor.Server.DepartmentViewer).
Navigate to the Views | MainDemo.Module.BusinessObjects | Department | Department_ListView node. In the DetailView drop-down list, select CustomDepartment_DetailView.
Run your Blazor application, navigate to the Department List View, open any Detail View, and see the result.