Migrating WP8 Silverlight based App to WP8.1 RT

From past one week I was working on migrating my app TV Shows Reminder. To be frank, my findings are, On the XAML side, I can say I have made almost 50% changes where as in the Code Behind, it was almost 40% changes. So a message to all the Devs, just go ahead and start migrating your apps. It doesn’t take a lot to migrate.

TV Shows Reminder is an App that works with the site http://reminders.programfreaks.com where you can search for your favorite TV Shows and then subscribe it right after you are logged in. The site will then send you an email whenever a new episode for the subscribed show is out!

Before migrating, you should list down all the features that your current app has. This will allow you to keep track of the features that you need to migrate. So let’s see all the features that I can think of before migrating.

  • Isolated Storage
  • Social Authentication
    • Facebook
    • Google
    • Microsoft
  • Live Tiles
    • Primary Tiles
    • Secondary Tiles
  • Background Agent
  • Lock screen Notification
  • Web APIs
  • WP Toolkit (Hub Tiles)
  • Appointments
  • System Tray
  • Message Box
  • Device Properties

Since my project architecture contained PCL, it was easier for me to migrate most of my code.

In order to migrate my app from Silverlight to RT, we tend to create a new WP 8.1 RT project.
Once we create the project, for making our task easier we simply start copying and start renaming the files. What we always forget is that the Xaml makes use of the code behind and sometimes we miss updating the references for the class file. Namespaces and class names are very important in this aspect as you entire application is dependent on them. In case you are making use of ReSharper, please suspend it at the moment. Since it confuses the developer with improper suggestions and warnings.

In order to achieve this, I added a new Pivot App (Windows Phone) Project.

Project Template in VS2013

Project Template in VS2013

Once, you add this project, it will automatically create a blank page which will help you in understanding the UI changes that are needed for your App to work properly. Also, you can reuse the newly created page for faster development.

In case you are copying and pasting your .xaml or the .cs code, make sure to update your class references properly.

Let’s look at some of the changes I had done for my app to run. Basically these changes were nothing but updating the class names and their respective namespaces. We will look at some of them below.

My App was also making use of the HubTiles which is present in the WPToolkit. Because the platform is now WinRT, I had to update my layout to display some other controls like Telerik Controls. Thankfully, Telerik provides free controls to MVPs and it has some controls which can be used as a replacement for my HubTile. Otherwise, I will have to make use of some images and text over it.

Also, my app has social authentication using Facebook, Google and Microsoft. In the current scenario, for Facebook , I was making use of the Facebook SDK. This SDK was solely built for Silverlight based apps. Since, all of the providers support OAuth, so I have switched all my authentication to make use of the WebAuthenticationBroker. It makes it easier to migrate the authentication for WP8.1 RT.

As discussed above, I am making use of the IsolatedStorageSettings to store the user’s data for the App. Since, in RT, IsolatedStorage is not available, I had to make use of the LocalSettings and had to store the images in the App Area.

For the live tiles and secondary tiles, I had to update my entire code since tiles in RT have completely different set of implementations than on Silverlight.

I am yet to migrate my Background Agent since it has completely different set of implementations in RT.

Let’s conclude here and look at some of the points to remember

  • Make sure you have updated your namespace and class names.
    • If missed, can give errors in InitializeComponent()
    • Many members of page would not be available
  • It is always better to reuse the xaml given in the new project than just copy pasting the entire code from earlier project.
    • Allows you to make use of the correct markup
    • Can easily view the similarity between the RT and Silverlight markup, thus allowing safe pasting in the xaml
  • The App.xaml.cs has different methods in RT than Silverlight. When  copying methods, it is better to copy the method definition to the appropriate method.
  • Some event names have got changed in the RT, make sure to update them in respective places.
  • Many event handlers in Silverlight were using the base class EventArgs which in RT is replaced by child class RoutedEventArgs as the parameters
  • Don’t forget to check the capabilities section to update the required capabilities.
  • In case of third party controls, check their WinRT counterpart to see if you can make use of those controls in WP8.1 RT.

Anubhav Ranjan

Software Engineer II at Microsoft

Anubhav is a Program Freak who loves coding and is currently working as a Software Engineer II in Xamarin Team at Microsoft. He is very passionate about Coding and loves developing Mobile Apps. At present, he helps C# Developers in taking their code across platforms. Also, pretty much interested in the latest ongoing trend which is Bots and AI. Currently working on Microsoft Bot Framework as well.
He is an active member of the BDotnet(Bangalore .NET) User Group and Speaker/Member of XHackers - A Community for Cross-Platform App Development.

Leave a Reply