Back to Devexpress

ListView.CreateCustomCurrentObjectDetailView Event

expressappframework-devexpress-dot-expressapp-dot-listview-417291f2.md

latest8.0 KB
Original Source

ListView.CreateCustomCurrentObjectDetailView Event

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

Namespace : DevExpress.ExpressApp

Assembly : DevExpress.ExpressApp.v25.2.dll

NuGet Package : DevExpress.ExpressApp

Declaration

csharp
public event EventHandler<CreateCustomCurrentObjectDetailViewEventArgs> CreateCustomCurrentObjectDetailView
vb
Public Event CreateCustomCurrentObjectDetailView As EventHandler(Of CreateCustomCurrentObjectDetailViewEventArgs)

Event Data

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

PropertyDescription
CurrentDetailViewSpecifies the Detail View displayed alongside the current List View.
DetailViewSpecifies a custom Detail View to be created.
DetailViewIdSpecifies the identifier of a custom Detail View to be created.
ListViewCurrentObjectSpecifies the current object of the current List View.
ListViewModelSpecifies the Application Model‘s node containing information on the currently displayed List View.
ListViewObjectTypeSpecifies 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:

ListViewCurrentObjectGets the currently selected object.ListViewObjectTypeGets the type of the current List View’s objects.CurrentDetailViewGets the current Detail View.ListViewModelGets 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 code snippet handles the CreateCustomCurrentObjectDetailView event for the following scenario:

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 a Detail View near the Employee 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 Employee_ListView node to your Detail View because, in this case, XAF uses this Detail View to edit an object in a separate window.

  1. Create a custom Detail View node in the Application Model’s Views node (“MyCustomDetailView” in this example) and enable ListViewAndDetailView mode for the Employee List View.
  2. 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.Blazor.Server\BlazorApplication.cs file in ASP.NET Core Blazor applications

  • C# (WinForms)

  • C# (Blazor)

csharp
public class MySolutionWinApplication : WinApplication {
    public MySolutionWinApplication() {
        ListViewCreated += MySolutionWinApplication_ListViewCreated;
    }
    private static void MySolutionWinApplication_ListViewCreated(object sender, ListViewCreatedEventArgs e) {
        if (e.ListView.Id == "Employee_ListView"){
            e.ListView.CreateCustomCurrentObjectDetailView += ListView_CreateCustomCurrentObjectDetailView;
        }
    }
    private static void ListView_CreateCustomCurrentObjectDetailView(object sender,
            CreateCustomCurrentObjectDetailViewEventArgs e) {
        e.DetailViewId = "MyCustomDetailView";
    }
}
csharp
public class MySolutionBlazorApplication : BlazorApplication {
    public MySolutionBlazorApplication() {
        ListViewCreated += MySolutionBlazorApplication_ListViewCreated;
    }
    private static void MySolutionBlazorApplication_ListViewCreated(object sender, ListViewCreatedEventArgs e) {
        if (e.ListView.Id == "Employee_ListView"){
            e.ListView.CreateCustomCurrentObjectDetailView += ListView_CreateCustomCurrentObjectDetailView;
        }
    }
    private static void ListView_CreateCustomCurrentObjectDetailView(object sender,
            CreateCustomCurrentObjectDetailViewEventArgs e) {
        e.DetailViewId = "MyCustomDetailView";
    }
}

See Also

ListView Class

ListView Members

DevExpress.ExpressApp Namespace