如何:打开消息框

更新:2007 年 11 月

本示例演示如何打开消息框。

示例

消息框是一种预制的模式对话框,用于向用户显示信息。通过调用 MessageBox 类的静态 Show 方法来打开消息框。调用 Show 时,使用字符串参数来传递消息。使用 Show 的几种重载,您可以配置消息框的显示方式(请参见 MessageBox)。

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