Archive for the ‘Resize’ Tag

Resize Silverlight 1.0 app to size of browser

OK, this is pretty simple, but I thought I would post if (at the very least for my reference).

Problem: How do I make the Silverlight application the size of my browser?

Solution:

  1. Add this line to the Page_Loaded event
    BrowserHost.Resize += new EventHandler(BrowserHost_Resize);
  2. Add this to the code behind file
    void BrowserHost_Resize(object sender, EventArgs e)
    {
    Width = BrowserHost.ActualWidth;
    Height = BrowserHost.ActualHeight;
    }
  3. (You may not have to do this step, but just in case) Comment out the CSS in the root html page
    /*.silverlightHost { width: 640px; height: 480px; } */

NOTE: this is for Silverlight 1.1