다음을 통해 공유


FrameworkElement.ActualWidth Property

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

Gets the rendered width of a FrameworkElement.

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

Syntax

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

Property Value

Type: System.Double
The width, 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 that you only rely on this property value when the passes that are involved in layout and in rendering for the relevant FrameworkElement are complete. ActualWidth 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 Width, which can be the basis of the input change.

The return value of ActualWidth 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, ActualWidth does not post updates when it changes (due to its asynchronous and run-time calculated nature). Do not attempt to use ActualWidth as a binding source for an ElementName binding. If you have a scenario that requires updates based on ActualWidth, 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.