Upgrading your Silverlight 2 Projects to Beta 2?

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:

Upgrade Dialog

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!

Comments:

Thanks Shawn, I think I've a ways to go upgrading my SL1 projects, but you've just solved my "GridSplitter is not supported in Silverlight" issue.

Many Thanks Phil

PS Do you know where the Datagrid control now lives? (no longer in Controls.Data by the looksof it :-) )

Phil,

The Data Grid is in System.Windows.Controls.Data.dll (and the same namespace) but you'll need to add that reference by hand.

Glad to help on GridSplitter.

Shawn

Hello,

Scott Guthrie, in his MS blog, linked to this page under the link "Upgrading your Silverlight 2 Projects to Beta2". However, the first line on this page is "There will be a lot of blogs about how to upgrade your projects from Beta 1 to Beta 2 so I won't add to the mix here".

Just wondering if anybody has found a good article that could help me to update my project from beta 1 to beta 2. Haven't had any luck finding anything yet.

I assumed that Tim Heuer and Jesse Liberty would fill that gap but since they haven't i'll update this post with my experiences.

I've posted a couple of times on my Beta 2 upgrade experiences. Its a new blog so probably hasn't shown up in search engines yet?

Thats at http://www.lythixdesigns.com/blog (I thought the url for my comment would show up in the comment but it didn't seem to.)

The Silverlight community is alive and well.
Stay in the light :)

For some reason my SL2b2 controls are displaying at 0 pixels by 0 pixels, despite the asp:Silverlight Height and Width properties set to 100%. Could this be a control templates issue? The control is loading and calls from within the Silverlight control that effect the DOM are going through, e.g. HtmlPage.Window.Invoke("globalJSMethod", messageArgs); ... but no visual display.

It could be a control template issue. My suggestion is to post the code and explanation on the official forums (http://silverlight.net/forums as its too hard to see code here.

BTW... here is a good resource: http://blogs.msdn.com/silverlight_sdk/pages/datagrid-beta-2-breaking-changes.aspx

http://blogs.msdn.com/silverlight_sdk/archive/2008/06/04/breaking-changes-for-silverlight-2-beta-2-corrections-and-additions.aspx

This one: "Can't get UI elements by name if hosted in ContentControl (ScrollViewers etc)." seems to be a dumb decision?

Some exhaustive testing indicates it might be FF2 specific.

http://silverlight.net/forums/t/18196.aspx


 



 
Save Cancel