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

2 comments so far

  1. Mohammed on

    Very simple, very fine🙂


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: