Closed Event
Collapse the table of content
Expand the table of content

ChildWindow.Closed Event


Occurs when the ChildWindow is closed.

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

Public Event Closed As EventHandler
<sdk:ChildWindow Closed="eventHandler"/>

To access the property values of a child window, handle the Closed event in the code-behind page of the calling window. In the Closed event handler cast the sender parameter to a ChildWindow or a derived class to access the child window properties.

The following example demonstrates how to handle the Closed event in the code-behind page of the parent window. The LoginWindow class is derived from ChildWindow. In the button click event handler, the LoginWindow is instantiated and a handler for the Closed event is attached. In the Closed event handler, the sender parameter is cast to a LoginWindow. It is then used to access the DialogResult property and the Name text box. This example is part of a larger example available in the ChildWindow class overview.

Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
    Dim loginWnd As New LoginWindow()
    AddHandler loginWnd.Closed, AddressOf loginWnd_Closed
End Sub
Private Sub loginWnd_Closed(ByVal sender As System.Object, ByVal e As EventArgs)
    Dim lw As LoginWindow = CType(sender, LoginWindow)

    If lw.DialogResult = True AndAlso lw.nameBox.Text <> String.Empty Then
        Me.helloTxt.Text = "Hello " + lw.nameBox.Text
    ElseIf (lw.DialogResult = False) Then
        Me.helloTxt.Text = "Login canceled."
    End If
End Sub


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

© 2016 Microsoft