Back to Devexpress

XafApplication.ListViewCreating Event

expressappframework-devexpress-dot-expressapp-dot-xafapplication-be150c86.md

latest4.2 KB
Original Source

XafApplication.ListViewCreating Event

Occurs when creating a List View.

Namespace : DevExpress.ExpressApp

Assembly : DevExpress.ExpressApp.v25.2.dll

NuGet Package : DevExpress.ExpressApp

Declaration

csharp
public event EventHandler<ListViewCreatingEventArgs> ListViewCreating
vb
Public Event ListViewCreating As EventHandler(Of ListViewCreatingEventArgs)

Event Data

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

PropertyDescription
CollectionSourceReturns the collection source to be used when creating a new List View.
IsRootIndicates whether a root View must be created. Inherited from ViewCreatingEventArgs.
ObjectSpaceReturns the Object Space to be used when creating a new View. Inherited from ViewCreatingEventArgs.
ViewSpecifies a custom List View created in a XafApplication.ListViewCreating event.
ViewIDReturns the ID of the created View. Inherited from ViewCreatingEventArgs.

Remarks

Handle this event to provide a custom List View instead of a default one. Use the handler’s ListViewCreatingEventArgs.View parameter to get information on the created List View. To do this, use the application’s XafApplication.FindModelView method passing the View ID as a parameter. To create a List View, use the collection source passed as the handler’s ListViewCreatingEventArgs.CollectionSource parameter. To specify whether the List View is root, use the handler’s ViewCreatingEventArgs.IsRoot parameter.

The following example demonstrates how to handle the ListViewCreating event:

csharp
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Model;

namespace MySolution.Module {
    public sealed partial class MySolutionModule : ModuleBase {
        public override void Setup(XafApplication application) {
            base.Setup(application);
            application.ListViewCreating += application_ListViewCreating;
        }
        void application_ListViewCreating(object sender, ListViewCreatingEventArgs e) {
            IModelListView modeListView = ((XafApplication)sender).FindModelView(e.ViewID) as IModelListView;
            if (modeListView != null) {
                modeListView.MasterDetailMode = MasterDetailMode.ListViewAndDetailView;
            }
        }
    }
}

See Also

XafApplication Class

XafApplication Members

DevExpress.ExpressApp Namespace