Sharing code between different platforms

Code sharing is one of the key concepts when developing applications with Xamarin. In this section, we will learn how to use the available options of sharing code between platforms when creating a Xamarin solution, Shared Project and Portable Class Library, and what the key differences are.

How to do it…

We will start with creating a solution based in Shared Project.

  1. Start Visual Studio. In the top menu, select File | New | Project… and in the Templates | Mobile Apps tab choose Blank App (Xamarin.Forms Shared). Name it XamFormsSharedProject, choose your directory path, and click OK.
  2. With that, you get four projects: the XamoFormsSharedProject core shared project and the corresponding Android, iOS, and Windows ...

Get Xamarin: Cross-Platform Mobile Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.