When handling the Execute event of an ActionBase class descendant, you can specify a View to be displayed after the Action execution. For this purpose, use the ShowViewParameters object passed as the Execute event handler's ActionBaseEventArgs.ShowViewParameters parameter. Set the View to be displayed for the CreatedView property. To specify the type of the Window that will contain the created View, use the TargetWindow property. To specify a Template context for the target Window, specify the Context property. In addition, you can specify the Controllers to be activated for the View and the Window to be displayed. For this purpose, use the Controllers collection. For instance, add a DialogController to this collection if the target Window is a pop-up. The following code demonstrates how to use a ShowViewParameters object in an Action's Execute event handler.
C# |
using DevExpress.ExpressApp.SystemModule;
void myAction_Execute(Object sender, SimpleActionExecuteEventArgs e) {
IObjectSpace objectSpace = Application.CreateObjectSpace(typeof(MyBusinessClass));
string listViewId = Application.FindListViewId(typeof(MyBusinessClass));
e.ShowViewParameters.CreatedView = Application.CreateListView(
listViewId,
Application.CreateCollectionSource(objectSpace,typeof(MyBusinessClass),listViewId),
true);
e.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow;
e.ShowViewParameters.Controllers.Add(Application.CreateController<DialogController>());
}
|
VB |
Imports DevExpress.ExpressApp.SystemModule
Private Sub MyAction_Execute(ByVal sender As Object, ByVal e As SimpleActionExecuteEventArgs)
Dim objectSpace As IObjectSpace = Application.CreateObjectSpace(GetType(MyBusinessClass))
Dim listViewId As String = Application.FindListViewId(GetType(MyBusinessClass))
e.ShowViewParameters.CreatedView = Application.CreateListView( _
listViewId, _
Application.CreateCollectionSource(objectSpace,GetType(MyBusinessClass),listViewId), _
True)
e.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow
e.ShowViewParameters.Controllers.Add(Application.CreateController(Of DialogController)())
End Sub
|
The properties specified for a ShowViewParameters object are considered by the active WinApplication.ShowViewStrategy or XafApplication.ShowViewStrategy which manages the Windows and Views display. In special scenarios, you may need to call the ShowViewStrategyBase.ShowView method to show a View. In this instance, you will have to create a ShowViewParameters object, and pass it as a parameter.
System.Object
ShowViewParameters