Archive for April, 2008

April 29th, 2008

Is your Silverlight not Rendering? Silverlight 1.0 CSS display bugs in IE7.

I recently ran across a bug where my Silverlight 1.0 content wasn’t rendering 100% of the time in Internet Explorer 7. It took nearly two days of searching before I stumbled onto a solution through trial and error.

It turns out that if you’re going to be toggling content visibility using CSS properties “display:none” and “display:block” then be aware that Internet Explorer has really wonky support for percentages used for width and height. It just doesn’t seem to render all the content accurately. The hardest thing to figure out is why it works half the time and then doesn’t the other half. This sucker was a pain to work through.

By default if you use the Silverlight 1.0 templates from Blend/VS2008 the createObjectEx function uses 100% for the height and width values of the Div containing your Silverlight Object. If you’re having problems with Silverlight not rendering as you’d expect, try changing the width and height to a numeric value rather than a percentage. Here is the Default:

Here is it updated and working:

As you can see I ONLY changed two things, but that made all the difference. Hopefully this tidbit of info will help others avoid spending tons of time trying to figure out why IE7 isn’t rendering their Silverlight Objects properly.