Resizing a Silverlight control speed bump

0
75

I’m trying to resize a Silverlight control on the fly. I’m using the code from this MSDN page.

Unfortunately in IE 7 I’m getting a size of zero for the Silverlight control’s actualwidth/actualHeight dimensions in the loaded event. This only happens in IE 7. In Firefox, I’m getting the correct size. Hmmm.

MSDN suggests the following code to set the original size to:

// Retrieve a reference to the control.
var control = sender.getHost();

// Do initial layout of the app based on initial size.
updateLayout(control.content.actualWidth, control.content.actualHeight);

Unfortunately, this gives a size of zero in IE in the loaded event.

To get around this I use:

var silverlightObj = document.getElementById(“silverlightObj”);
updateLayout(silverlightObj.clientWidth, silverlightObj.clientHeight);

Seems to work in IE and Firefox. I need to test in Safari.