CTICoder

A random spillage of programming (and other) thoughts

  • Welcome!

    Enjoy the random thoughts, but only if you really want to.
  • a

  • Archives

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.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>