Click here to Skip to main content
15,880,299 members
Articles / Mobile Apps / Xamarin

Xamarin.Forms: One UI to Rule Them All?

Rate me:
Please Sign up or sign in to vote.
4.53/5 (13 votes)
27 Jun 2014CPOL3 min read 23.6K   11   4
Xamarin.Forms: One UI to Rule Them All?

Xamarin 3.0 has recently introduced Xamarin.Forms, a powerful UI abstraction that allows developers to easily create user interfaces that can be shared across Android, iOS, and Windows Phone.

Introducing Xamarin.Forms

Xamarin.Forms apps follow the same architecture xamarinmvvmthat traditional cross-platform applications, except there is an additional –new- project. It’s the main component here that makes everything possible.

Behind the scene what is a Xamarin.Forms project? It’s just a Portable Class Library (PCL) or a Shared Project. Shared projects were introduced with Visual Studio 2013 update 2 to provide Universal Apps. It’s a little like file linking but with a better integration into VS.

This project depends on the Nuget package Xamarin.Forms, which contains more than 40 controls and UI components. It also comes with cross devices UI components such as Binding, Navigation and Dependency Injection.

There are two ways to create shared-UI views: programmatically, using the API provided by Xamarin.Forms or with XAML using the same set of controls (is it the beginning of XAML everywhere?) It’s a new independent meta-language to define your UI. An UILabel (iOS), TextView (Android) or TextBlock (WP) is simply a Xamarin.Forms.View.Label. It’s also possible to create custom controls and UserControls and define renderers for each platform. Fantastic!

Without Xamarin.Forms, you have to understand each layout system to build a native UI. Now with Xamarin.Forms, you design only once. These two samples give the same result:


Both techniques provide advantages and drawbacks but from my point of view, the biggest problem is that you don’t have any designer to preview the UI or even intellisense: It’s important to understand that’s it’s a completely new set of controls you have to learn without any help from Visual Studio. I hope I‘m sure Xamarin will improve this soon because it’s quite counter-productive. Feel free to propose an answer to this question on stackoverflow.

Read the official introduction guide here.

What about MvvmCross?

If you follow Xamarin community since a few months – like me, you may already have heard about MvvmCross, a framework that allows developers to share logic between multiple platforms. It’s mainly maintained by Stuart Lodge and is a brilliant cross MVVM abstraction. Even better, this framework comes with an awesome list of features such as cross-platform binding, dependency injection, a plugin system, many services (Navigation, Location, Camera, …) and a few UI controls to maximize code sharing and avoid breaking the Mvvm Pattern. The combo PCL+MvvmCross+Xamarin is often called “The Precious” aka “One language to rule them all”.

Can you use it with Xamarin.Forms? Yes, because Xamarin.Forms was designed to work with the MVVM design pattern (but no included). However, much of what MvvmCross gives you is already baked in. Xamarin.Forms comes with features like DI, Navigation … whereas MvvmCross comes with ready-to-use implementations like plugins. For example, do you want to use GeoLocation (typically GPS) functionality? Install the MvvmCross package in your solution or create 3 implementations (one per platform) with Xamarin.Forms. I think we will see new packages in the coming weeks/months for common devices sensors and services. That’s another disadvantage of this first version of Xamarin.Forms: you have to reinvent the wheel in some cases. In reality, the ambiguity may also come from MvvmCross itself because it’s not only a simple cross MVVM framework; with all the features that are included, it’s much more a Cross platform framework than MVVM framework.

highres_379493672So, yes there is a little overlap between these two frameworks but this should not prevent to use them both. From my point of view, Xamarin.Forms is not an MvvmCross-killer but a fantastic new path for cross-platform development. You now have the chance to share code and UIs.

Finally, I was last week in the 3rd Xamarin meetup in Paris with James Montemagno. I really appreciated the presence of Xamarin for this event. I am quite pleased to see the French community growing so fast. Is it only in France?


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Technical Lead
France France
Yet another proof of concept

Comments and Discussions

GeneralMy vote of 5 Pin
Ștefan-Mihai MOGA20-Jul-14 4:38
professionalȘtefan-Mihai MOGA20-Jul-14 4:38 
QuestionOne UI and High-Quality UI May Be Not the Same Thing Pin
abdurahman ibn hattab29-Jun-14 16:03
abdurahman ibn hattab29-Jun-14 16:03 
AnswerRe: One UI and High-Quality UI May Be Not the Same Thing Pin
Cybermaxs30-Jun-14 21:35
Cybermaxs30-Jun-14 21:35 
AnswerRe: One UI and High-Quality UI May Be Not the Same Thing Pin
Kai Friis28-Jul-14 20:29
Kai Friis28-Jul-14 20:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.