Back to Devexpress

ShowViewStrategyBase.ShowViewInPopupWindow(View, Action, Action, String, String, Frame, Action<ShowViewParameters>) Method

expressappframework-devexpress-dot-expressapp-dot-showviewstrategybase-dot-showviewinpopupwindow-x28-view-action-action-string-string-frame-action-showviewparameters-x29.md

latest8.4 KB
Original Source

ShowViewStrategyBase.ShowViewInPopupWindow(View, Action, Action, String, String, Frame, Action<ShowViewParameters>) Method

Shows the specified View in a popup dialog with OK and Cancel buttons.

Namespace : DevExpress.ExpressApp

Assembly : DevExpress.ExpressApp.v25.2.dll

NuGet Package : DevExpress.ExpressApp

Declaration

csharp
public void ShowViewInPopupWindow(
    View view,
    Action okDelegate = null,
    Action cancelDelegate = null,
    string okButtonCaption = null,
    string cancelButtonCaption = null,
    Frame sourceFrame = null,
    Action<ShowViewParameters> configureDelegate = null
)
vb
Public Sub ShowViewInPopupWindow(
    view As View,
    okDelegate As Action = Nothing,
    cancelDelegate As Action = Nothing,
    okButtonCaption As String = Nothing,
    cancelButtonCaption As String = Nothing,
    sourceFrame As Frame = Nothing,
    configureDelegate As Action(Of ShowViewParameters) = Nothing
)

Parameters

NameTypeDescription
viewView

A View to be displayed in the pop-up window.

|

Optional Parameters

NameTypeDefaultDescription
okDelegateActionnull

A delegate method that is executed when the OK button is clicked.

| | cancelDelegate | Action | null |

A delegate method that is executed when the Cancel button is clicked.

| | okButtonCaption | String | null |

The caption of the OK button.

| | cancelButtonCaption | String | null |

The caption of the Cancel button.

| | sourceFrame | Frame | null |

A Frame from which the pop-up window is invoked.

| | configureDelegate | Action<ShowViewParameters> | null |

A delegate method that allows you to configure View parameters before creating the pop-up window.

|

Remarks

The ShowViewInPopupWindow method displays a dialog that contains the specified View and two buttons - OK and Cancel. Both buttons close the dialog.

csharp
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<MyDialog>();
        MyDialog myDialogObject = objectSpace.CreateObject<MyDialog>();
        myDialogObject.Message = "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 string Message { get; set; }
}

Advanced Example

This code sample calls the ShowViewInPopupWindow method and accesses the following information inside the method implementation:

  • the initial view and its objects;
  • the pop-up view and its objects;
  • the ShowViewParameters and its objects;
  • the dialog controller for configuration.
csharp
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,
            (showViewParameters) => {
                var dialogController = (DialogController)showViewParameters.Controllers.First(ctrl => ctrl is DialogController);
                dialogController.AcceptAction.SelectionDependencyType = SelectionDependencyType.RequireSingleObject;
            }
        );
    }
}

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.

The following code snippets (auto-collected from DevExpress Examples) contain references to the ShowViewInPopupWindow(View, Action, Action, String, String, Frame, Action<ShowViewParameters>) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

xaf-win-custom-button-in-lookup-property-editor/CS/EFCore/LookUpButtonEF/LookUpButtonEF.Win/Editors/MyLookupPropertyEditor.cs#L34

csharp
var view= Helper.Application.CreateDetailView(objectSpace, editedObject, true);
    Helper.Application.ShowViewStrategy.ShowViewInPopupWindow(view);
}

XAF_how-to-show-filter-dialog-before-listview/CS/EFCore/DialogBeforeListViewEF/DialogBeforeListViewEF.Module/Controllers/ShowFilterDialogController.cs#L41

csharp
filterDetailView.Caption = string.Format("Filter for the {0} ListView", View.Caption);
    Application.ShowViewStrategy.ShowViewInPopupWindow(filterDetailView, () => FilterDetailView_OK(filterDetailView));
}

See Also

ShowViewStrategyBase Class

ShowViewStrategyBase Members

DevExpress.ExpressApp Namespace