Udostępnij za pośrednictwem


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)

Syntax

'Declaration
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
)

Parameters

  • 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.

Exceptions

Exception Condition
ArgumentNullException

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

-or-

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

-or-

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

ArgumentException

button is not a valid MessageBoxButton value.

Remarks

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

Silverlight

Supported in: 5

Platforms

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