共用方式為


Silverlight: The OnLoad event

Lots of folks have been asking questions around their WPF/E applications and why the onLoad event that worked nicely with the CTPs breaks in the Silverlight 1.0 beta.

Well, it's because the onLoad event signature has changed, and unfortunately the documentation with the beta hasn't fully caught up yet in all of its examples.

So, if you were previously writing an OnLoad event handler that looked like this:

 

function handleLoad(sender,args)
{
// Do my app logic
}

 

You should change it to this:

 

function handleLoad(control, userContext, rootElement)
{
// Do my app logic
}

 

The first parameter is a reference to the Silverlight control, so no more getHost() calls from within your load handler.

The second parameter is a reference to the user context, a free format string that is a property you can set up when you are instantiating your control with the createSilverlight() function.

The third parameter is a reference to the root element hosted by teh Silverlight control.

 

Much more useful, but unfortunately you'll need to modify any onLoad functions that you've previously written for WPF/E...

 

Laurence

Comments

Scott/MSFT

  • Anonymous
    July 20, 2007
    does the controls actualheight and actualwidth of the silverlight control get set prior to the onLoad event?