ShowViewStrategyBase.ShowViewInPopupWindow(View, Action, Action, String, String, Frame) Method
Shows the specified View in a popup dialog with OK and Cancel buttons.
Namespace: DevExpress.ExpressApp
Assembly: DevExpress.ExpressApp.v24.1.dll
NuGet Package: DevExpress.ExpressApp
Declaration
Parameters
Name | Type | Description |
---|---|---|
view | View | The View that this method shows in a pop-up window. |
Optional Parameters
Name | Type | Default | Description |
---|---|---|---|
okDelegate | Action | null | The Action delegate that this method executes when the OK button is clicked. This parameter is optional. |
cancelDelegate | Action | null | The Action delegate that this method executes when the Cancel button is clicked. This parameter is optional. |
okButtonCaption | String | null | The custom caption of the OK button. This parameter is optional. |
cancelButtonCaption | String | null | The custom caption of the Cancel button. This parameter is optional. |
sourceFrame | Frame | null | The parent Frame of the View that this method shows in a pop-up window. This parameter is optional and used in WinForms applications only. |
Remarks
The ShowViewInPopupWindow
method displays a dialog that contains the specified View and two buttons - OK and Cancel. Both buttons close the dialog.
The following example demonstrates how to use this method:
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.DC;
// ...
public class MyDialogController : ViewController {
public MyDialogController() {
SimpleAction action = new SimpleAction(this, "Email", "View");
action.Execute += Action_Execute;
}
private void Action_Execute(object sender, SimpleActionExecuteEventArgs e) {
IObjectSpace objectSpace = Application.CreateObjectSpace(typeof(MyDialog));
MyDialog myDialogObject = new MyDialog("Do you want to send an email?");
DetailView dialogView = Application.CreateDetailView(objectSpace, myDialogObject);
Application.ShowViewStrategy.ShowViewInPopupWindow(dialogView,
() => Application.ShowViewStrategy.ShowMessage("Done."),
() => Application.ShowViewStrategy.ShowMessage("Cancelled."),
null, null, this.Frame
);
}
}
[DomainComponent]
public class MyDialog {
public MyDialog(string message) {
this.Message = message;
}
public string Message { get; private set; }
}
The advanced example below shows how to use the ShowViewInPopupWindow
method to:
- access the initial view and its objects,
- access the pop-up view and its objects.
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
using MySolution.Module.BusinessObjects;
namespace MySolution.Blazor.Server.Controllers;
public class CustomBlazorController :ObjectViewController<DetailView, Contact> {
public CustomBlazorController() {
var myAction = new SimpleAction(this, "MyBlazorAction", PredefinedCategory.Edit);
myAction.Execute += MyAction_Execute;
}
private void MyAction_Execute(object sender, SimpleActionExecuteEventArgs e) {
var objectSpace = Application.CreateObjectSpace(typeof(Contact));
var listView = Application.CreateListView(typeof(Contact), true);
Application.ShowViewStrategy.ShowViewInPopupWindow(listView,
() => {
var mainViewObject = ((Contact)View.CurrentObject);
var popupViewObjects = listView.SelectedObjects;
Application.ShowViewStrategy.ShowMessage($"The main view's current object is {mainViewObject.FirstName}. The number of selected objects in the pop-up view is: {popupViewObjects.Count}");
},
() => Application.ShowViewStrategy.ShowMessage("Cancelled."),
null, null, this.Frame
);
}
}
You can also use PopupWindowShowAction to show a View in a pop-up window. For more information, refer to the following help topic: Add an Action that Displays a Pop-Up Window.
Note
ASP.NET Web Forms applications have the following specifics:
- You can use the ShowViewInPopupWindow method on XafCallbackManager callbacks that the RaiseXafCallback script initiates. You cannot use it on control callbacks (for example, grid sorting).
- It is not possible to pause the current request to wait for user input.
- The main window is not refreshed when the Cancel button is clicked.