WPF Dialogs


In your WPF application, what is a dialog and how do you create and show dialogs? A dialog is a modal subwindow. Modal means that it pops up and requires a response from the user. With these dialogs, you can handle common tasks such as opening and saving files, browsing folders, printing choosing colors, choosing fonts and browsing folders and drives. There are two types of dialogs:

  • Common Dialogs
  • Custom Dialogs

WPF does not natively render common dialogs. It internally calls Win32 APIs to show them and communicate with them. This means that dialogs remain consistent with the version of the operating system on which the application is running.

You can create your own custom dialog that mimics the functionality of a common dialog, but you shouldn’t. Why not? Users expect a certain look and feel to their common dialogs. Also, it is unlikely that you will include all of the features that a common dialog provides because some of those features are hidden.

MessageBox is a type of dialog.

The Open file dialog has been used in a few posts here at begincodingnow.com.