Learn how to share code between different platforms using Xamarin.Forms technology.
- [Man] One of the beauties of Xamarin and the Xamarin Forms platform, is that we can share 95, 96, 97, even 98% of our code across all platforms. And right now, in Xamarin forms, there are currently two methods for sharing code across platform project. The first one is a portable class library or PCL, and the other is a shared project. Shared project is a more recent mechanism for sharing code in Xamarin forms project and it's very similar to a shared project in the Windows 8 and 8.1 time frame.
Let's talk about a couple of the key differences and why we might choose either one. So typically you'd create a project to use a portable class library or PCL, if you ever want to reuse the code outside of your project in any way. And, in general, a portable class library is referenced by your platform-specific project, like your IOS or Android app, and compiled separately from the app itself. A shared project has the advantage of having the files compiled in the app itself.
Shared project also has the ability to do conditional compilation. For example, if you want specific code only to run for Android or only to run for IOS, you would typically create a shared project. One of the limitations of a shared project is you can't use that content outside of the project itself. Both methods for code sharing have their advantages and disadvantages. The most common scenario is using a portable class library and that's what we'll be using in this series.
- Code sharing concepts
- Basic UI concepts
- Layout controls
- Using pages and layouts
- Adaptive layouts
- Creating complex layouts
- Adding robust navigation and controls