MessageBox.Show Method (Window, String, String, MessageBoxButton)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Displays a message box that is modal to the window specified by the owner parameter.

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


Public Shared Function Show ( _
    owner As Window, _
    messageBoxText As String, _
    caption As String, _
    button As MessageBoxButton _
) As MessageBoxResult
public static MessageBoxResult Show(
    Window owner,
    string messageBoxText,
    string caption,
    MessageBoxButton button


  • owner
    Type: System.Windows.Window
    A window reference that represents the top-level window that will own the modal dialog box.

Return Value

Type: System.Windows.MessageBoxResult
A MessageBoxResult value that indicates the user's response to the message.


Exception Condition

messageBoxText is nulla null reference (Nothing in Visual Basic).


owner is nulla null reference (Nothing in Visual Basic).


caption is nulla null reference (Nothing in Visual Basic).


button is not a valid MessageBoxButton value.


This method is only applicable to trusted out-of-browser applications. If it is called in an application that does not have elevated permissions and is out-of-browser, the message box will be modal to the web-browser main window.

Version Information


Supported in: 5


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