Getting Started with Silverlight - Part 3
Getting Started with Silverlight: Part 3
Interacting with the Silverlight Control Programmatically
EMBED element representing the Silverlight control (whether part of the static HTML document or dynamically injected by
Silverlight.js) has an HTML
Because this element is an instance of the ActiveX object (or Netscape plug-in), it provides a number of useful properties, functions, and events specific to Silverlight. This element returned by
document.getElementById is the same object passed as the first parameter to the
onLoad event handler. However, you should avoid accessing any Silverlight-specific members on this object before the control has finished loading (and its
onLoad event is raised).
The Silverlight control exposes most of its functionality via two properties:
Most relevant to this chapter is the control's Settings property, which defines a number of subproperties for getting or setting a number of attributes (many of which could have alternatively been set via createObject, createObjectEx, or directly on the OBJECT/EMBED element):
For example, the
Background properties can be set in a Silverlight
onLoad event handler as follows:
In addition, the Boolean properties can be set to a
false string or to a
false Boolean literal, and they work correctly either way.
None of the
Settings members are extremely compelling, however, as it's rare you would need to retrieve or change the data after the control has loaded.