System.Windows Namespace


.NET Framework Class Library for Silverlight
MessageBox Class

Displays a message to the user and optionally prompts for a response.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)
Syntax

Visual Basic (Declaration)
Public NotInheritable Class MessageBox
Visual Basic (Usage)
Dim instance As MessageBox
C#
public sealed class MessageBox
Remarks

The MessageBox class provides a static Show method that you can use to display a message in a simple dialog box. The dialog box is modal and provides an OK button.

An overload of the Show method enables you to specify a title bar caption and an optional Cancel button. If you display a Cancel button, you can use the return value of the method to determine the user's response.

The message box may have a slightly different appearance on different platforms. For example, the message box includes an icon when it is displayed on a Macintosh.

Examples

The following example code demonstrates how to use this class.

Visual Basic
Dim result As MessageBoxResult = _
    MessageBox.Show("Would you like to see the simple version?", _
    "MessageBox Example", MessageBoxButton.OKCancel)

If (result = MessageBoxResult.OK) Then
    MessageBox.Show("No caption, one button.")
End If
C#
MessageBoxResult result = 
    MessageBox.Show("Would you like to see the simple version?", 
    "MessageBox Example", MessageBoxButton.OKCancel);

if (result == MessageBoxResult.OK)
{
    MessageBox.Show("No caption, one button.");
}
Inheritance Hierarchy

System..::.Object
  System.Windows..::.MessageBox
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also

Reference

Tags :


Page view tracker