Back to Devexpress

How To: Create a Modal Message Box Flyout

windowsforms-14886-controls-and-libraries-application-ui-manager-views-windowsui-view-getting-started-how-to-create-a-modal-message-box-flyout.md

latest2.1 KB
Original Source

How To: Create a Modal Message Box Flyout

  • Oct 29, 2020
  • 2 minutes to read

This example demonstrates how to create a simple modal Windows8-like message box via a Flyout.

  1. Create a new WindowsUI View application, or open an existing one.

  2. Open the DocumentManager’s context menu and run the Designer.

  3. Switch to the ‘Elements’ section and select ‘Content Containers’. Click the ‘Add New Container’ button and choose ‘Flyout’ from the drop-down list.

  4. Select the newly created Flyout and change its name to closeAppFlyout via the property grid.

  5. Switch to the code view and create a FlyoutAction object that will display message text and buttons for the Flyout.

  6. Optionally you can specify the background color for the solid bar that will display the message box. To do so, customize the Appearance section, which is accessed via the WindowsUIView.FlyoutProperties property.

  7. Associate the FlyoutAction with the Flyout via the Flyout.Action property.

  8. Now handle the main form’s FormClosing event. Use the WindowsUIView.ShowFlyoutDialog method to call the Flyout. This method will freeze the form’s thread, and show the Flyout in a separate thread. The ShowFlyoutDialog method returns a System.Windows.Forms.DialogResult value that indicates which button was clicked by the end-user. Depending on this value, you can allow or cancel form closing.

  9. Start your application and try to close the form. A modal message box Flyout will appear.