Ticket T403174
Visible to All Users

DetailView as popup

created 9 years ago

I'm building my first prototype with XAF and have a question. I have a simple class with just 5 properties. This show fine in the listview with 5 columns, but as a detailview there is a lot of 'white space' on the screen. Therefore I want the detailview to always open as a modal popup. There is no need for a ribbon on the popup, just an OK / Cancel button to save or cancel the changes.

Also on the main ribbon I'd like a button to add a new object by opening this simple popup form.

How can I do this?

My primary target is a Win app, but a Web solution would also be interesting.

Answers approved by DevExpress Support

created 9 years ago

Hello Birger,

To accomplish this task, you can handle the ListViewProcessCurrentObjectController.CustomizeShowViewParameters event as shown below:

C#
using DevExpress.ExpressApp.SystemModule;  public class ViewController1 : ViewController<ListView> { protected override void OnActivated() { base.OnActivated(); Frame.GetController<ListViewProcessCurrentObjectController>().CustomizeShowViewParameters += ViewController1_CustomizeShowViewParameters; } void ViewController1_CustomizeShowViewParameters(object sender, CustomizeShowViewParametersEventArgs e) { e.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow; e.ShowViewParameters.Context = TemplateContext.PopupWindow; e.ShowViewParameters.Controllers.Add(Application.CreateController<DialogController>()); } protected override void OnDeactivated() { base.OnDeactivated(); Frame.GetController<ListViewProcessCurrentObjectController>().CustomizeShowViewParameters -= ViewController1_CustomizeShowViewParameters; } }

Refer to the How to show DetailView shown by the New and Edit actions in a popup window ticket for additional information.

To show this form using a button in the ribbon control, use the following solution: Add an Action that Displays a Pop-up Window. This topic shows how to create a ListView. To create a DetailView, use the XafApplication.CreateDetailView method. Alternatively, you can use a SimpleAction and call the ListViewProcessCurrentObjectController.ProcessCurrentObjectAction.DoExecute method in its Execute event handler to emulate the default double click functionality.

Let me know if you need further assistance.

    Comments (3)

      Hi Anatol,

      I got it working for when I open the ListView of this class and then add or edit a new item.
      When I have another window open and use the (XAF deafult) New item in the ribbon it doesn't show as a popup. Can I change this behaviour as well?

        Also, I'd like the button allways be visible in the ribbon, not just when the listview is active. Even when no forms are opened I'd like to have the button in the mainform ribbon.

        Anatol (DevExpress) 9 years ago

          You can define which views your controller customizes as described in the How do I specify in which View a Controller should be activated? topic. For example, to customize the New action in all views, do not set the controller's TargetObjectType, TargetViewID and other similar parameters, and do not specify the view type and object type in the base class' generic parameters.
          To show an action in a window that does not contain any views, declare this action in a WindowController.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.