Upgrading your Silverlight 2 Projects to Beta 2?

June 6, 2008
No Comments.

Silverlight Logo
UPDATED: Essentially, no one else did write a bunch of upgrading blogs so I’ve amended this blog post to include more infomation on how to upgrade your projects.

When opening your projects in Visual Studio after Silverlight 2 Beta 2, you will be prompted to upgrade your project as shown below:

This upgrade with change the project references for you and in most cases remove the **System.Windows.Controls.Extended.dll **reference. Once the project is converted, you will see a number of changes to make:

  • Tooltips have changed and some functionality has been removed.  For the most part changing from ToolTip=“…” to ToolTipService.ToolTip=“…” will fix most simple usage of the control.
  • If you’re not using the Calendar, GridSplitter or DatePicker, remove the System.Windows.Controls.Extended.dll from your references.  You don’t need it for most controls anymore and its pretty big so it will just balloon the size of your .xap files.
  • If you are using ControlTemplates, you may need make a lot of changes. Look again at the default templates (Reflector is a good way of getting the generic.xaml that contains all the templates) to see how you should change them.  TemplateParts have changed names and they are mostly using VisualStateManager for transition effects. Alternatively, the Blend support for VisualStateManager is really good and removing your ControlTemplates and recreating them with Blend is often the better solution.
  • If you are using the DataGrid control, you will need to do a substantial amount of re-work as the DataGrid has changed a heck of a lot. The biggest change for most people is that AutoGenerateColumns is now true by default.
  • Upgrade to the new Silverlight.js to your project if you are using it to host your project.  Its is in the SDK directory under “Tools”.
  • If you are using the OBJECT tag to include Silverlight, you will need to change the MIME type from “application/x-silverlight-2-b1” to “application/x-silverlight-2-b2”.
  • If you use WebClient, you may need to add a reference to System.Net.dll.
  • When you use any networking code (WebClient, et al.), it used to throw exceptions during the execution (on the other thread) which breaks the APM model.  Silverlight 2 now throws this exception when you retrieve the results on the callback.  This means you will need to trap those errors with try…catch blocks around the results reference in the callback.
  • Any DeepZoom images will need to be regenerated with Deep Zoom composer as the format of the file (was .bin, now .dzi or .dzc) has changed to XML.
  • Web service use has changed and now actually reads the .clientconfig file.  So if you are having trouble getting your services working, make sure the values in the .clientconfig  file are accurate.
  • Dynamic XAML (using XamlReader.Load) has changed so that a private namescope is created by default. This is a significant change that means that referring to named elements inside your Dynamic XAML (or using FindName to locate an item) will fail.
  • x:Key and x:Name for Resources are now mutually exclusive.  If you were doing the trick of using an x:Key so that you could do StaticResource but using x:Name to get a reference in your code-behind file, this no longer works.  To get the item in your codebehind, call Resource[“keyname”] instead.
  • IsolatedStorage defaults have been increased from 1KB to 10MB. If you need to increase the API has changed to IsolatedStorageFile.IncreaseQuotaTo.
  • OpenFileDialog.ShowDialog now returns a boolean instead of a DialogResult.
  • WatermarkedTextBox has been removed, you will need to replace these with simple TextBox.

The SDK comes with a deeper document that discusses all the changes that are important.  Read this…I only have covered the big picture items.

Hope this helps those of you doing late night conversions like I am doing!