ChildWindow.OnOpened Method


This method is called every time a ChildWindow is displayed.

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

protected virtual void OnOpened()

The base implementation of OnOpened sets the overlay brush and opacity if an overlay exists, and it makes sure that the child window can be tabbed to with the keyboard.

You can override OnOpened to perform any actions needed by your application when a child window is opened.

The following code example demonstrates how to override the OnOpened method. This code randomly selects between two different videos to be played when the child window opens. This example is part of a larger example available in the ChildWindow class overview.

protected override void OnOpened()

    Random random = new Random();
    if ((int)random.Next(0, 2) == 1)
        this.splashMedia.Source = new Uri("/Silverlight1.wmv", UriKind.RelativeOrAbsolute); ;
        this.splashMedia.Source = new Uri("/Silverlight2.wmv", UriKind.RelativeOrAbsolute);


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