Silverlight 1.0 and OnLoad

There are some changes for the OnLoad event handler from older beta versions (code name WPF/E). In Silverlight 1.0 beta you will use following event handler, now:

function handleLoad(control, userContext, rootElement)
{
  // Add your code here
} 

The first argument is a reference to the host control, so there is no need to call sender.getHost() inside the load handler.

Second argument is the user context which is a simple string that you can pass with the properties when instantiating the control with createSilverlight().

Last parameter will be a reference to the root element hosted by the Silverlight control.

The createSilverlight() call looks now like this:

function createSilverlight()
{  
   Sys.Silverlight.createObject(
"test.xaml", document.getElementById("WpfeControl1Host"),
"wpf", { width:"100%", height:"100%", inplaceInstallPrompt:false, background:'white', isWindowless:'true', framerate:'30', version:'0.95', enableHtmlAccess:'true' }, {onError:null, onLoad:MyLoad}, null, {text:"my user context"} ); }

For the userContext in the documentation I found: "userContext of type Object". Until today the userContext is only loop through, so you can use any object, string or whatever you need.

Published Friday, June 01, 2007 7:38 AM by Michael Schwarz

Comments

# Silverlight Cream for June 1, 2007

Friday, June 01, 2007 12:18 PM by Community Blogs

Cream , as in 'Pick of the Litter' is always subjective, but this is my list for today as I view