Microsoft Silverlight will reach end of support after October 2021. Learn more.
Occurs when either the ActualHeight or the ActualWidth properties change value on a FrameworkElement.
Assembly: System.Windows (in System.Windows.dll)
'Declaration Public Event SizeChanged As SizeChangedEventHandler
public event SizeChangedEventHandler SizeChanged
Use a handler based on SizeChangedEventHandler to handle this event.
The Silverlight layout system reads properties in the SizeChangedEventArgs event data class of this event, to determine whether the reported size changes should be considered significant. This allows the layout system to avoid forcing a layout change because of visually imperceptible differences between old and new height or width values. The imperceptible differences might be caused by rounding or calculations of a floating-point value.
The SizeChanged event uses specialized event data derived from RoutedEventArgs, not EventArgs. However, the event does not bubble (it does not travel a true event route).
It is not strictly necessary to avoid calling other APIs that influence layout of the current object from within a SizeChanged handler. For example: setting Height or Width; calling InvalidateMeasure or UpdateLayout; calling ApplyTemplate; any operation that might resize child elements and thus invalidate the parent layout. The layout engine has internal logic that is capable of avoiding many looping issues. However, it is still possible to create sizing or rendering loops if your handler logic combined with surrounding layout is not capable of reaching an end result for the size of the relevant object.
SizeChanged is raised whenever the size (either ActualHeight or ActualWidth) has changed on the object, and is raised after the Measure and Arrange passes are complete (for more information about these concepts, see Silverlight Layout System). If the position of the object within a parent container changes, but not the size, SizeChanged is not raised.
LayoutUpdated is a similar event, but LayoutUpdated is also raised for position changes. In addition, LayoutUpdated occurrence is not scoped to a specific object's layout properties, and is instead reporting on the entire visual tree that an object is contained in. LayoutUpdated informs you that something within the overall visual tree that contains the object has changed, but the layout specifics (size, position) of the object where the handler is attached might not have changed.
Supported in: 5, 4, 3
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.