Поделиться через


ChildWindow.Close Method

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

Closes a ChildWindow.

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

Syntax

'Declaration
Public Sub Close
public void Close()

Remarks

By default, a user can close a ChildWindow in one of two ways:

  • SHIFT+CTRL+F4.

  • Close button.

These mechanisms will always set the DialogResult to false.

The typical way to programmatically close a ChildWindow is to set the DialogResult value. Setting the DialogResult automatically calls the Close method.

You can also call the Close method directly to close a ChildWindow. This will always set the DialogResult to false.

You can cancel the closing of the child window in the event handler of the Closing event.

Examples

The following example demonstrates a child window that closes automatically when the video it contains has ended. This example is part of a larger example available in the ChildWindow class overview.

Run this sample

Private Sub splashMedia_MediaEnded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
    Me.Close()
End Sub
private void splashMedia_MediaEnded(object sender, RoutedEventArgs e)
{
    this.Close();
}

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

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