Skip to main content
.NET 6.0+

ListView.CreateCustomCurrentObjectDetailView Event

Occurs when the current List View is updated, and when its current object is changed.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v23.2.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public event EventHandler<CreateCustomCurrentObjectDetailViewEventArgs> CreateCustomCurrentObjectDetailView

Event Data

The CreateCustomCurrentObjectDetailView event's data class is CreateCustomCurrentObjectDetailViewEventArgs. The following properties provide information specific to this event:

Property Description
CurrentDetailView Specifies the Detail View displayed alongside the current List View.
DetailView Specifies a custom Detail View to be created.
DetailViewId Specifies the identifier of a custom Detail View to be created.
ListViewCurrentObject Specifies the current object of the current List View.
ListViewModel Specifies the Application Model‘s node containing information on the currently displayed List View.
ListViewObjectType Specifies the type of the objects displayed by the current List View.

Remarks

You can display a Detail View to the right or at the bottom of a List View. This Detail View displays the object selected in the List View. To enable this mode, set the IModelListView.MasterDetailMode property of the Application Model‘s Views | <ListView> node to ListViewAndDetailView. To display an alternate Detail View, you can use one of the following techniques:

  • Specify the IModelListView.MasterDetailView property in the Model Editor. Note that when both MasterDetailView and DetailView properties are unspecified, XAF automatically determines the Detail View based on the type of the object created or edited in the List View (the IModelClass.DefaultDetailView value specified for a specific object type is used).
  • Handle the CreateCustomCurrentObjectDetailView event and specify the handler’s DetailView or DetailViewId parameter. Note that when you specify the DetailViewId parameter, XAF creates a Detail View with the passed identifier automatically.

When you use the second technique, you can implement custom logic to choose a Detail View and use the following handler’s parameters to access and customize additional details:

ListViewCurrentObject
Gets the currently selected object.
ListViewObjectType
Gets the type of the current List View’s objects.
CurrentDetailView
Gets the current Detail View.
ListViewModel
Gets the Detail View currently set for the current List View in the Application Model (see the Views | <ListView> node’s IModelListView.DetailView property).

The following example demonstrates how to handle the CreateCustomCurrentObjectDetailView event. Assume you created a custom Detail View node in the Application Model’s Views node (“MyCustomDetailView” in this example) and enabled ListViewAndDetailView mode for the Person List View. You want to display this Detail View near the Person List View but do not want to use this Detail View to edit the List View’s object in a separate window. You cannot set the DetailViewID property of the Person_ListView node to your Detail View because, in this case, XAF uses this Detail View to edit an object in a separate window. To solve your task, handle the CreateCustomCurrentObjectDetailView event and set the DetailViewId parameter to your Detail View in one of the following places:

  • Controller
  • MySolution.Win\WinApplication.cs file in WinForms applications
  • MySolution.Web\WebApplication.cs file in ASP.NET Web Forms applications
  • MySolution.Blazor.Server\BlazorApplication.cs file in ASP.NET Core Blazor applications
public class MySolutionWinApplication : WinApplication {
    public MySolutionWinApplication() {
        ListViewCreated += MySolutionWinApplication_ListViewCreated;
    }
    private static void MySolutionWinApplication_ListViewCreated(object sender, ListViewCreatedEventArgs e) {
        if (e.ListView.Id == "Person_ListView"){
            e.ListView.CreateCustomCurrentObjectDetailView += ListView_CreateCustomCurrentObjectDetailView;
        }
    }
    private static void ListView_CreateCustomCurrentObjectDetailView(object sender,
            CreateCustomCurrentObjectDetailViewEventArgs e) {
        e.DetailViewId = "MyCustomDetailView";
    }
}
See Also