MessageBox lets you configure the message box text, title, icon, and buttons.įor more information, see How to open a message box. To create a message box, you use the MessageBox class. The following figure shows a message box that asks a question and provides the user with three buttons to answer the question. Message boxesĪ message box is a dialog box that can be used to display textual information and to allow users to make decisions with buttons. This article discusses each, and the Dialog Box Sample provides matching examples. With WPF you can create several types of dialog boxes, such as message boxes, common dialog boxes, and custom dialog boxes. Other buttons may be provided to run specific functions, such as a Find Next button to find the next word in a word search. A modeless dialog box at least provides a Close button to close the dialog box. Since the application doesn't want to prevent the user from editing the document, the dialog box doesn't need to be modal. For example, if a user wants to find occurrences of a particular word in a document, a main window will often open a dialog box to ask a user what word they're looking for.
The most common dialog boxes are used to show an open file or save file prompt, displaying the printer dialog, or messaging the user with some status.Ī modeless dialog box doesn't prevent a user from activating other windows while it's open. Once the modal dialog box is closed, the application continues. Other windows in the application can't be interacted with until the dialog box is closed. This generally comes in the form of a prompt or alert. A dialog box can be displayed in two ways: modal and modeless.ĭisplaying a modal dialog box to the user is a technique with which the application interrupts what it was doing until the user closes the dialog box. These types of windows are known as dialog boxes. Display an operating system prompt, such as print window.This article discusses how a dialog box works and what types of dialog boxes you can create and use. Dialog boxes are windows but with a specific intent and user experience. Windows Presentation Foundation (WPF) provides ways for you to design your own dialog boxes.