Udostępnij za pośrednictwem


HtmlDocument.DocumentReady Event

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

Occurs when the browser page has completely loaded.

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

Syntax

'Declaration
Public Event DocumentReady As EventHandler
public event EventHandler DocumentReady

Remarks

This event corresponds to the following JavaScript code:

document.readystate == complete;

You can register an event handler for the DocumentReady event. This enables you to receive a notification when the HTML page that contains the Silverlight plug-in has been fully parsed and all DOM objects are available for programming.

The DocumentReady event is raised only once: when the document is ready. If you subscribe to this event after the containing HTML document has been completely loaded, the event is never raised.

To receive ready state notifications, use the following code:

// Place all initialization code in the readyHandler.
EventHandler readyHandler = delegate { …. };
// First check if the document is already in a ready state.
If (HtmlPage.Document.IsReady)
   { readyHandler(this, EventArgs.Empty);}
// Otherwise, subscribe to the DocumentReady event.
else {
HtmlPage.Document.DocumentReady += readyHandler;
}

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.