The Loaded event can be defined for any UIElement-derived class, such as Canvas, TextBlock, and Rectangle.
You can also add handlers in script by using a quoted string for the event handler name, as follows:
object.AddEventListener("Loaded", "eventhandlerFunction")
This syntax also returns a token. However, the token is not an absolute requirement for removing the handler in cases where the handler was added by using a quoted string. For details, see RemoveEventListener.
You can define multiple Loaded events for objects in XAML content. However, if a child object and its parent object both define a Loaded event, the child object's Loaded event occurs before the parent object's Loaded event. This is because the page root cannot consider itself loaded until all its constituent parts are loaded.
Certain properties have an implicit or explicit asynchronous behavior and do not block the Loaded event. For example, if you use a Downloader object to set an image source, the image will initially load with no source and Loaded will still occur. After the asynchronous download is completed, the associated Downloader will raise the Completed event.
Caution: |
|---|
The alert() mechanism that is provided in JavaScript on browsers is not a reliable way to examine the order in which events are raised. Frequently the alerts will not consistently follow the true order of the events. Instead of using alert(), use the technique shown in this topic and write out log messages to a plug-in on the page, or something similar. |