Export (0) Print
Expand All

ActualWidth Property (Silverlight Plug-in)

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

Scripting (Instantiation) Not directly set during instantiation, but influenced by instantiation width value.
Scripting
value = silverlightObject.content.ActualWidth

Property Value

integer

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

This property is read-only. The default value is the height of the Silverlight plug-in, as specified by the OBJECT/EMBED tag that instantiated it. If height was specified by percentage during initialization this is a calculated pixel value. For more information on how this property is set during plug-in initialization, see Instantiating a Silverlight Plug-in (Using CreateSilverlight.js and Silverlight.js).

Remarks

This property is available on the content sub-object of a Silverlight plug-in instance.

Important   In the early stages of the object lifetime of a Silverlight plug-in instance, ActualHeight and ActualWidth do not contain a usable value. The OnLoad event does not yet guarantee a correct value for ActualHeight or ActualWidth. In general, you should check these values in the handler for the OnResize event, which occurs just thereafter.

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

  • embedded mode: plug-in displays within the Web browser.
  • full-screen mode: plug-in displays on top of all other applications.

When the Silverlight plug-in is in embedded mode, the value of ActualWidth depends on whether the width of the Silverlight plug-in is specified as a fixed-width or percentage value. The width of the Silverlight plug-in is defined in the OBJECT tag of the containing Web page. If the width of the Silverlight plug-in is a fixed-width value, such as "400", ActualWidth is set to the plug-in width. If the width of the Silverlight plug-in is a percentage value, such as "100%", ActualWidth is set to the most appropriate width for displaying the plug-in in the browser. In this case, resizing the browser window width causes the ActualWidth value to change.

When the application is in full-screen mode, the value of ActualWidth is set to the current horizontal resolution of the display.

The OnResize event occurs whenever 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 OnResize event does not occur.

Examples

The following JavaScript example shows how to use the ActualWidth and ActualHeight properties. In the case where width is defined as a percentage value, the ActualWidth value represents a numeric width value, interpreted in pixels:

JavaScript
function onResizeStatus(sender, eventArgs)
{
    // Concatenate the size values as a formatted message string.
    var msgString  = " actualWidth: " + slPlugin.content.actualWidth;
        msgString += " actualHeight: " + slPlugin.content.actualHeight;

    // Display an alert dialog box with a formatted message string.
    var textBlock = sender.findName("Status");
    textBlock.text = msgString;
}

Applies To

Silverlight Plug-in

See Also

Instantiating a Silverlight Plug-in (Using CreateSilverlight.js and Silverlight.js)
Resizing a Silverlight Plug-in
Silverlight Full-screen Support
ActualHeight
OnResize

Community Additions

Show:
© 2014 Microsoft