Condividi tramite


FrameworkElement.ActualHeight Property

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

Gets the rendered height of a FrameworkElement.

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

Syntax

'Declaration
Public ReadOnly Property ActualHeight As Double
public double ActualHeight { get; }

Property Value

Type: System.Double
The height, in pixels, of the object. The default is 0. The default might be encountered if the object has not been loaded and undergone a layout pass.

Remarks

Be sure you only rely on this property value when the passes that are involved in layout and in rendering for the relevant FrameworkElement are complete. ActualHeight is a calculated value, and there can be multiple or incremental reported changes to the value because of operations by the layout system. If you get the value while layout is still iterating, the layout system might still be calculating the required measure of space for child objects, constraints by the parent object, and so on. Because the value is based on an actual rendering pass, it may lag slightly behind the set value of properties like Height, which can be the basis of the input change.

The return value of ActualHeight might also reflect the influence of layout rounding. Certain containers (notably TextBlock) might return values that are not rounded, regardless of layout rounding settings. For more information, see Layout Rounding.

For purposes of ElementName binding, ActualHeight does not post updates when it changes (due to its asynchronous and run-time calculated nature). Do not attempt to use ActualHeight as a binding source for an ElementName binding. If you have a scenario that requires updates based on ActualHeight, use a SizeChanged handler.

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.