This documentation is archived and is not being maintained.

FrameworkElement.Loaded Event

Occurs when the element is laid out, rendered, and ready for interaction.

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

Public Event Loaded As RoutedEventHandler
Dim instance As FrameworkElement 
Dim handler As RoutedEventHandler 

AddHandler instance.Loaded, handler
<object Loaded="RoutedEventHandler" .../>

Identifier field


Routing strategy




Loaded is usually the last event raised in an element initialization sequence. It will always be raised after Initialized. Whether you choose to handle Loaded or Initialized depends on your requirements. If you do not need to read element properties, intend to reset properties, and do not need any layout information, Initialized might be the better event to act upon. If you need all properties of the element to be available, and you will be setting properties that are likely to reset the layout, Loaded might be the better event to act upon. Be careful of reentrancy if your handler resets any properties that are interpreted by the layout system to mean that a new layout pass is required. (You might need to check the FrameworkPropertyMetadata values on the property if you are unsure of which properties can require a new layout pass if they are changed.)

For more information about the sequence of object events for a FrameworkElement, and also for several related application and element classes, see Object Lifetime Events.

Direct routed events do not follow a route, they are only handled within the same element on which they are raised. Direct routed events do support other routed event behavior: they support an accessible handlers collection and can be used as an EventTrigger in a style.

Loaded and Unloaded might both be raised on controls as a result of user-initiated system theme changes. A theme change causes an invalidation of the control template and the contained visual tree, which in turn causes the entire control to unload and reload. Therefore Loaded cannot be assumed to occur only when a page is first loaded through navigation to the page.

This example shows how handle the FrameworkElement.Loaded event, and an appropriate scenario for handling that event. The handler creates a Button when the page loads .

The following example uses Extensible Application Markup Language (XAML) together with a code-behind file.

Private Sub OnLoad(ByVal sender As Object, ByVal e As RoutedEventArgs)
    Dim b1 As Button = New Button()
    b1.Content = "New Button"
    b1.Height = 25
    b1.Width = 200
    b1.HorizontalAlignment = HorizontalAlignment.Left
End Sub

For the complete sample, see Loaded Event Sample.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0