Scott Hanselman

Upgrading your project from Silverlight 1.1 Alpha to Alpha Refresh

July 31, 2007 Comment on this post [2] Posted in Silverlight
Sponsored By

I am by no means a Silverlight expert. That said, here's the things I personally needed to do to update an existing Silverlight 1.1 Alpha project to Silverlight 1.1 Alpha Refresh.

First, I loaded up my existing Visual Studio 2005 project in Visual Studio 2008 Beta 2 and went through the conversion wizard. No warnings, no errors, but the wizard won't touch your JavaScript.

Next, I add a FRESH New Silverlight Project to my solution. I added this project for reference, and I'll delete it later.

I did a diff between the .js's that I had and the new one. Notice a few changes:

Silverlight.createObjectEx({
    source: "Page.xaml",
    parentElement: document.getElementById("SilverlightControlHost"),
    id: "SilverlightControl",
    properties: {
        width: "100%",
        height: "100%",
        version: "1.1",
        enableHtmlAccess: "true"
    },
    events: {}
});

You don't refer to the Silverlight object via Sys.Silverlight any more. Also, enableHtmlAccess takes a string "true" when before a boolean worked for me. Also, the version has changed to "1.1".

Previous Silverlight project wizards or samples might have put this in your body's onload:

<body onload="document.getElementById('SilverlightControl').focus()">

Now, if you want your control to have initial focus, you need to add the onload in a friendlier way:

// Give the keyboard focus to the Silverlight control by default
    document.body.onload = function() {
      var silverlightControl = document.getElementById('SilverlightControl');
      if (silverlightControl)
      silverlightControl.focus();
    }
You'll also need to copy the new "minimized" Silverlight.js file and notice that its size has been nearly cut in half by the process. Shiny.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
July 31, 2007 14:43
Looks like you've already started your new job. Congrats again Scott.
July 31, 2007 22:31
Thanks for this brilliant post. I've been trying to run my Silverlight project after updating to VS 2008 Beta 2 and with no luck. After I updated the project with you instructions everything started to work. Brilliant.. Thanks

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.