Freigeben über


ChildWindow.Show Method

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

Opens a ChildWindow and returns without waiting for the ChildWindow to close.

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

Syntax

'Declaration
Public Sub Show
public void Show()

Exceptions

Exception Condition
InvalidOperationException

The child window is already in the visual tree.

Remarks

When the ChildWindow class is instantiated, it is not visible by default. The Show method displays the child window and returns immediately, without waiting for the child window to close. This lets activity on the parent window, such as an animation, continue while the child window is open. However, the parent window is disabled as long as the child window is open, so that user interaction with the parent window is not possible.

When the child window is opened, if there are elements that have their IsTabStop property set to true, the element with the lowest TabIndex will get focus. However, if there are no elements that have their IsTabStop property set to true, no focus is set.

To detect when a child window is shown, you can override the OnOpened method.

Examples

The following code demonstrates how to instantiate a ChildWindow, set its content, and then show it. This example is part of a larger example available in the ChildWindow class overview.

Dim cw As New ChildWindow
cw.Content = "Please enter name and password or click Cancel."
cw.Show()
ChildWindow cw = new ChildWindow();
cw.Content = "Please enter name and password or click Cancel.";
cw.Show();

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.