Freigeben über


FrameworkElement.LayoutUpdated Event

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

Occurs when the layout of the Silverlight visual tree changes.

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

Syntax

'Declaration
Public Event LayoutUpdated As EventHandler
public event EventHandler LayoutUpdated
<frameworkElement LayoutUpdated="eventhandler"/>

Remarks

LayoutUpdated is the last object lifetime event to occur in the sequence before a control is ready for interaction. However, LayoutUpdated can also occur at run time during the object lifetime, for a variety of reasons: a property change, a window resizing, or an explicit request (UpdateLayout or ApplyTemplate). The LayoutUpdated event is raised after all possible SizeChanged events in the tree have been raised.

In WPF, this event is a routed event, and is actually on UIElement not FrameworkElement. In Silverlight, this event is not a routed event; it is a standard CLR event that uses EventArgs, not RoutedEventArgs.

LayoutUpdated can occur when the object where the handler is attached does not necessarily change anything in the visual tree under it. For instance, imagine a layout container where there are two elements. If the first object changes a property that forces a new layout, both objects raise LayoutUpdated because the second object might be repositioned even if its own subsidiary layout does not change.

When you handle LayoutUpdated, do not rely on the sender value. For LayoutUpdated, sender is always nulla null reference (Nothing in Visual Basic), regardless of where the handler is attached. This is to prevent handlers from assigning any meaning to sender, such as implying that it was that specific element that raised the event out of the visual tree. Rather, LayoutUpdated implies that something in the overall Silverlight visual tree has changed, and each specific object anywhere in the tree has the option of handling this occurrence. The Silverlight version of LayoutUpdated has this behavior in part to maintain WPF compatibility.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.