ChildWindow.Close Method


Closes a ChildWindow.

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

public void Close()

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


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

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 void splashMedia_MediaEnded(object sender, RoutedEventArgs e)


Supported in: 5, 4, 3

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

Community Additions