OnLoad (Silverlight Plug-in Object)

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

Establishes the handler for a Loaded event that occurs when the Silverlight plug-in has finished loading into the browser DOM.


object Element

<object ...>
  <param name="onload" value="functionname"/>




You can get the value, but the value is just the function name.



Managed Code

Not available directly. Most scenarios can be addressed by handling either the FrameworkElement.Loaded event from the page root, or by handling the Application.Startup event.


The Loaded event occurs after the content in the Silverlight plug-in has completely loaded. For managed code, the content is typically a .xap file that contains a primary assembly along with loose or embedded resources specified in a manifest. The primary assembly contains one or more XAML files, including the application definition and the start page. For the JavaScript API, the content is a single XAML file.

You cannot attach handlers to the Loaded event after plug-in initialization, because a forced reload of a Silverlight plug-in does not preserve any state.

In general, do not make sizing decisions in a handler for the Loaded event. The values of the ActualHeight and ActualWidth properties of the Silverlight plug-in are not guaranteed to be set at the time that the Loaded event occurs. Instead, handle the Resized event, which occurs when the ActualHeight or ActualWidth properties change, including when the plug-in first loads.

The Loaded event in the DOM occurs after the FrameworkElement.Loaded event occurs for the root visual of the current page. The root element's FrameworkElement.Loaded event generally occurs after the FrameworkElement.Loaded event has occurred for all child elements under the root (although there are certain exceptions, such as items in an ItemsControl, which sometimes load after the root).

The read-only IsLoaded property is set just before the Loaded event occurs. This property indicates whether the Silverlight plug-in is loaded.

You can add handlers for the Silverlight.js version of the Loaded event (for example, when you use Silverlight.createObject). The Silverlight.js library wraps the native plug-in implementation of the event. The wrapped version uses a different signature and a different model for an OnLoad event handler, which includes a context. For more information about the Silverlight.js version of OnLoad, see Silverlight.js Reference.

Arguments for an OnLoad Function



The Silverlight plug-in that raised the event.


Always null.