Appendix A. Silverlight JavaScript Reference

Using the Silverlight Plug-in

There are two ways to access the Silverlight plug-in. One is to use the HTML DOM and the document.getElementById() method, and provide the ID used in the createSilverlight() function. The other is to intercept any Silverlight event and access the plug-in in the following fashion:

function eventHandler(sender, eventArgs) {
  var plugin = sender.getHost();
}

From the plug-in, you have access to the following properties and methods:

content.accessibility

Accessibility information of the Silverlight content (read-only).

content.actualHeight

The height of the Silverlight content (read-only).

content.actualWidth

The width of the Silverlight content (read-only).

content.createFromXaml(xamlContent, nameScope)

Creates a Silverlight object with the given XAML content; if nameScope is set to true, a unique x:Name attribute is assigned.

content.createFromXamlDownloader(downloader, part)

Creates a Silverlight object from the given downloader object; if the downloaded content is a ZIP archive, part defines the name of the file to use.

content.findName(objectName)

Returns a reference to the object with the given name.

content.fullScreen

Whether the Silverlight plug-in is in full-screen mode (read and write).

content.onFullScreenChange

Event handler that is fired when the application enters or leaves full-screen mode.

content.onResize

Event handler that is fired if the Silverlight content area is resized.

createObject(objectType)

Creates and returns an object with the given type.

initParams

The initialization parameters provided for the Silverlight content (read-only after the initialization).

isLoaded

Whether the Silverlight plug-in and its XAML content are fully loaded (read-only).

isVersionSupported(versionString)

Whether the current Silverlight plug-in supports content with the given version number.

onError

Event handler that is fired if an error occurs within the Silverlight application.

root

The root element of the Silverlight content (read-only).

settings.background

The background color of the Silverlight content area (read and write).

settings.enabledFramerateCounter

Whether the current frame rate is displayed in the browser’s status bar (read and write; note that not all browsers allow you to change the content of the status bar).

settings.enableRedrawRegions

Whether the regions of the Silverlight content that are redrawn are highlighted (read and write; useful only during development).

settings.enableHtmlAccess

Whether to allow Silverlight content to access the HTML DOM (read-only).

settings.maxFrameRate

The maximum frame rate (number of frames) of the Silverlight content (read and write).

settings.windowless

Whether the Silverlight application runs in windowless mode (then the background may use alphatransparency and can let the background on the HTML page shine through), set in the initialization phase (read-only afterward).

source

The XAML source code of the Silverlight content (read and write).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.154.18