Silverlight Scripting Application Notes
This topic contains the following section:
Silverlight stores all numeric values internally as single-precision values.
This means that if a property value is set to a higher precision value, such as a double, the property value that is later retrieved may not be the same, due to truncation or rounding.
A floating point can be no larger than +/- 1,000,000.
The following XAML example shows how to attach a handler for the Loaded event for the
Canvas
object. Notice that the reference to the event handler function name is not
prefixed by "javascript:". That prefix was required for
early prerelease versions of Silverlight, then made optional in later prerelease versions, but is not permitted in the release versions.
| XAML |
<Canvas
xmlns="http://schemas.microsoft.com/client/2007"
Loaded="onLoaded" />
|
The equivalent operation in script is to call the AddEventListener method. The second AddEventListener parameter that specifies the event handler function can be in two general forms: a quoted string of the function name, or a reference to the function name. For instance to parallel the XAML above, you could use either the syntax rootCanvas.addEventHandler("Loaded","onLoaded") or rootCanvas.addEventHandler("Loaded",onLoaded). You can also use a variation of the second syntax by explicitly creating a delegate for your function.
AddEventListener returns a token value that is necessary if you intend to remove that event handler through runtime script. For details see AddEventListener.
See Also
Silverlight Object Models,
Using Silverlight Plug-ins,
Silverlight Events