Portable Class Libraries - Shared Core for Windows 8 and Windows Phone 8 Apps

16 November 2012

I'm a little late to the party, but I started looking into creating a new WP8 the other day, and figured I'd try and make it as reusable as possible for a possible Win 8 port - and Portable Class Libraries, something that used to be an extension is now fully baked into Visual Studio 2012.

Basically, PCL projects allow you to share code between disparate technologies - Windows Phone, Silverlight, .NET, Store Apps. While they only support a subset of whatever's available between the platforms you've selected, there's quite a lot of code that you can share - in XAML land, a large majority of everything ViewModel down can be common code. I've tried it, it works, it's amazing.

Here's the MSDN link to get you started: buried in there is also what to do when you want to call into methods or code that isn't available within PCL (under the Platform Abstraction header). The basic idea is to use an abstract class, and override the implementations in the platform-specific projects (ie in your Phone and Win 8 projects, individually).

With PCL, it looks like I'll be able to make a drastic saving on the time required to port to different platforms, drastically. Nice work, Microsoft!

Tags: PCL, VS2012, Windows 8, Windows Phone 8

Add a Comment

No Comments