How to: Open a Message Box

This example shows how to open a message box.


A message box is a prefabricated modal dialog box for displaying information to users. A message box is opened by calling the static Show method of the MessageBox class. When Show is called, the message is passed using a string parameter. Several overloads of Show allow you to configure how a message box will appear (see MessageBox).

void showMessageBoxButton_Click(object sender, RoutedEventArgs e) {
  // Configure message box
  string message = "Hello, MessageBox!";
  // Show message box
  MessageBoxResult result = MessageBox.Show(message);

Community Additions