CTICoder

A random spillage of programming (and other) thoughts

Setting a Silverlight canvas to full width/height of the browser in Silverlight 2

Posted by Michael Bray on October 19, 2008

This article shows how to set the canvas width and height for the page, but apparently some things broke since the page was written and Silverlight 2 came out.  In order to do this properly in Silverlight 2, use Application.Current.Host.Content in place of BrowserHost as described in the article. 

Strangely, you can achieve the same thing by removing the Width and Height tags on the main UserControl.  In the designer, this will make it appear as if the control is AutoSizing down to the contents of the subcontrols, but in the actual application it will take the full size of the browser if you have the height style set to 100% on body, form, and div of the containing element of the asp:Silverlight control as well as the Width and Height parameters set to 100% on the control itself.

Advertisements

3 Responses to “Setting a Silverlight canvas to full width/height of the browser in Silverlight 2”

  1. Very informative post. Really a lot of useful information. Very happy I found your blog. Will bookmark it and check back for more information.

  2. Vuyiswa said

    nice indeed

  3. asp.net, c#,javascript…

    […]Setting a Silverlight canvas to full width/height of the browser in Silverlight 2 « CTICoder[…]…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: