Thursday, June 25, 2015 Eric Richards

Xamarin Forms Succinctly - Review

Recently, I've started work on developing a mobile application to interface with one of my employer's server-side products. Because this product is primarily a C# .NET application, we decided to take a look at using Xamarin.Forms, so that we could leverage parts of our existing code-base and also make use of Xamarin's cross-platform capabilities, rather than developing separate native clients using Java on Android, Objective-C on iOS, or C# on Windows Phone. Since we are primarily a C#/HTML/CSS/JS shop, the potential time-savings of being able to reuse our current expertise in .NET programming languages, and only having to learn the Xamarin framework, as opposed to two additional languages and three mobile development frameworks was a huge plus - particularly as some of the technologies that we would use to interact with our server-side product are not officially supported from the native platforms to the same degree as their .NET implementations.

Time will tell if Xamarin.Forms is the correct long-term solution for our needs - on the one hand, our particular application does not need much in the way of device-specific capabilities and customization that Xamarin does not provide access to, but on the other, the licensing costs for Xamarin are somewhat steep. At least for the purposes of rapidly throwing together a prototype proof-of-concept and exploring the feasibility of the idea, using Xamarin.Forms has been a great success - in the equivalent of one week of developer time, we were able to produce a fully-functional prototype.

While I was able to throw together something workable in a short period of time working from the Xamarin sample code, a variety of blog posts, and trawling the Xamarin Forms development forums, the task would have been much easier, and I would have avoided some missteps, if I had taken the time to read a brief overview of the technology beforehand. About midway through the prototype, I happened upon Xamarin Forms Succinctly, which is that quick overview that I was looking for. It is a quick read, at only 148 pages in the PDF version, but it provides a good surface treatment of the concepts and techniques for building simple Xamarin Forms applications - I printed out a copy, put it in a three-ring binder and read through it over the course of a couple of evenings and lunch breaks. It helped a great deal in filling in some of the blanks that I had missed in my more haphazard initial exploration, and it was a great help in revising some of the issues and antipatterns from the inital prototype version of our app.

I would definitely recommend that anyone who is interested in investigating Xamarin Forms and seeing what the technology offers take a few hours and read through Xamarin Forms Succinctly. For the price (free, other than registering an account with SyncFusion), and the time investment required (minimal), it is hard to beat. Besides, it's a gateway into the large library of free, generally high-quality, Succinctly ebooks, which cover a vast array of technical topics in a quick, accessible format.

With the fragmented landscape of mobile device platforms, tools for creating cross-platform apps have sprung up as varied and numerous as apps themselves. Most of these tools create their own APIs and translate them into the mobile platform APIs, which works fine for some. And then there’s Xamarin.Forms, which creates mappings from its C# classes and controls directly to the native platform APIs and controls. With Xamarin.Forms Succinctly by Derek Jensen, you will learn how to use Xamarin.Forms to build a common code base that can be deployed to iOS, Android, and Windows Phone devices, coming as close as possible as to the mythical “write once, run everywhere.” You’ll also learn how to build UIs with some of the 40 controls included in Xamarin.Forms, and even how to access native APIs that aren’t exposed by Xamarin.Forms.

Table of Contents

  1. Introduction
    What is Xamarin.Forms, why would you use it, what are some of it's advantages, how to get started.
  2. Code Sharing
    Portable Class Libraries, Shared Projects, and why you would choose one or the other
  3. Hello, Xamarin.Forms
    Hello World, a la Xamarin.Forms
  4. Introduction to XAML
    10000 foot overview of XAML, code-behind and data-binding
  5. Building User Interfaces
    The different Page types and page Layouts available out of the box in Xamarin.Forms
  6. Common Controls
    Overview of out-of-the-box UI controls available in Xamarin.Forms
  7. Customization
    Custom platform-specific control rendering and creating custom controls
  8. Accessing Native APIs
    Dependency-injection and accessing platform-specific capabilities not exposed through Xamarin.Forms
  9. Messaging
    Decoupled message-passing using Xamarin.Forms

Pros

  • Free
  • Very quick-reading and accessible
  • Features many code examples illustrating the concepts covered, using both XAML and code. Screenshots showing the results of code snippets for iOS, Android and Windows Phone
  • Solid overview of the Xamarin.Forms platform
  • Available in both PDF and Kindle (.mobi) formats

Cons

  • Not a deep-dive - to go beyond the basics you will need to find a more comprehensive resource, or explore the wild west of blog posts, stackoverflow questions, and development forums
  • I didn't find any discussion of integration with external web-services, which seems like it would be an enormously common use-case
  • No discussion of Device.BeginInvokeOnMainThread, which is necessary for updating UI elements from background threads - in my case, this was critical to discover, as our application makes use of SignalR to push data from our server-side application to the app
  • The final chapter "Messaging" seemed to be a little half-baked. I'm not entirely sure what the advantages of using the MessagingCenter functionality showcased are; the example in the chapter is a little contrived.

Bookshelf

I have way too many programming and programming-related books. Here are some of my favorites.