Silverlight to resize to 100% with IE8

Had a frustrating time getting a Silverlight control to take up 100% height of the browser page. First off, this is nothing really to do with Silverlight and all about the div it’s contained in. In IE7 having the div at 100% worked fine, but in IE8 it was tiny. The problem is that in IE7 a div at 100% means, ‘please take up 100% of the available height’. Whereas in IE8 it’s, ‘please take up 100% of your parent’. So a structure like

html->body->div->div[100%]->Silverlight Control
means that in IE8 its height is basically nothing. So I added 100% to the parents up to body and still no joy. Then Hannah at Clear Breeze Design pointed out that I needed to apply it to the html tag too. That did the trick. So if you have a very simple layout you could do something like;

 html * {height 100%}

Even in my code that’s too simple but the basic take-away is that you need to follow the ancestors from the Silverlight control up until you hit a height, that’s the one it will take. If you want it to be 100% then must ensure that everyone on that chain is 100% too, including body and html.

Silverlight with ASP.NET http context gotcha

Encountered an old problem at work today. A Silverlight application which talks to an svc on the same web host wasn’t correctly sharing the same session. You could see this as the httpContext was different between the web site calling the Silverlight control and the site receiveing a request from Silverlight. It’s a simple problem; when you add a refrence to a service Visual Studio will create an endpoint in the config file, something like However, when you test you might just use localhost. If there is a mismatch then the session will NOT be shared. I tend to pass the endpoint address from the web site in the Silverlight initParams, I find this easier than trying to post the .host by your milage may vary. NB. This is also important when hosting on a system that uses some form of https proxy as this causes the host to look like http but you need to pass https from the client, e.g. your Silverlight control.