Share via


ActualWidth (Silverlight Plug-in Object)

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

Gets the width of the rendering area of the Silverlight plug-in.

Syntax

object Element

Not applicable. This property is not settable on instantiation. However, the width property of the object element is settable and affects the ActualWidth value.

Silverlight.js

Not applicable. This property is not settable on instantiation. However, the width parameter of the CreateObject and CreateObjectX functions is settable and affects the ActualWidth value.

JavaScript

value = silverlightObject.content.ActualWidth;

COM

IXcpControl::Content gets an IDispatch interface, which you can use to call ActualWidth.

Managed Code

Property Value

The width of the rendering area of the Silverlight plug-in, in pixels.

This property is read-only for all means of access. The default value is the width property value of the Silverlight plug-in, as specified by the object element that instantiated it. If width was specified by percentage during initialization, this is a calculated pixel value.

Remarks

Important noteImportant Note:

In the early stages of the object lifetime of a Silverlight plug-in, ActualHeight and ActualWidth do not contain usable values. In particular, when the DOM Loaded event occurs, correct values for ActualHeight and ActualWidth are not guaranteed. In general, you should check these values in the handler for the Resized event, which occurs just after Loaded whenever a Silverlight plug-in is first instantiated on an HTML page. If Resized occurs again, it indicates that ActualHeight or ActualWidth have changed at run time, and any saved values should be adjusted.

A Silverlight plug-in can be displayed in either embedded mode or full-screen mode:

  • In embeddedmode, the plug-in is displayed in the Web browser content area.

  • In full-screen mode, the plug-in is displayed on top of all other applications.

When the Silverlight plug-in is in embedded mode, the value of ActualWidth depends on whether the height of the Silverlight plug-in is a pixel count or a percentage value. The width of the Silverlight plug-in is defined in the object element of the containing HTML page. (The actual object element and its width might be specified indirectly, through Silverlight.js helper functions or through an ASP.NET control.) If the width is a pixel count value, such as 300, ActualWidth is set to the plug-in width. If the width of the Silverlight plug-in is a percentage value, such as "100%", ActualWidtht is set to the most appropriate width for displaying the plug-in in a browser. In this case, if the browser window height is changed (either through a user action or by manipulating the HTML DOM), the ActualWidth value changes also.

When the application is in full-screen mode, the value of ActualWidth is set to the current horizontal resolution of the user's display. For more information, see Full-Screen Support.

The Resized event occurs whenever the calculated values of the ActualHeight and ActualWidth properties change, and the Silverlight plug-in is in embedded mode. When the Silverlight plug-in is in full-screen mode, the Resized event does not occur. If the mode changes (from embedded to full-screen, or full-screen to embedded) then the Resized event does not occur. The FullScreenChanged event occurs instead.