Saturday, October 14, 2017

Introducing Xamarin.Forms

On May 28, 2014, Xamarin introduced Xamarin.Forms, which allows you to write user-interface code that can be compiled for the iOS, Android, and Windows devices.

The Xamarin.Forms option
Xamarin.Forms supports five distinct application platforms:

 iOS for programs that run on the iPhone, iPad, and iPod Touch.

 Android for programs that run on Android phones and tablets.

 The Universal Windows Platform (UWP) for applications that runs under Windows 10 or Windows 10 Mobile.

 The Windows Runtime API of Windows 8.1.

 The Windows Runtime API of Windows Phone 8.1.

In the general case, a Xamarin.Forms application in Visual Studio consists of five separate projects for each of these five platforms, with a sixth project containing common code. But the five platform projects in a Xamarin.Forms application are typically quite small—often consisting of just stubs with a little boilerplate startup code. The PCL or SAP contains the bulk of the application, including the user-interface code. The following diagram shows just the iOS, Android, and Universal Windows Platform. The other two Windows platforms are similar to UWP:

The Xamarin.Forms.Core and Xamarin.Forms.Xaml libraries implement the Xamarin.Forms API. Depending on the platform, Xamarin.Forms.Core then makes use of one of the Xamarin.Forms.Platform libraries. These libraries are mostly a collection of classes called renderers that transform the Xamarin.Forms user-interface objects into the platform-specific user interface.

The remainder of the diagram is the same as the one shown earlier.

For example, suppose you need the user-interface object discussed earlier that allows the user to toggle a Boolean value. When programming for Xamarin.Forms, this is called a Switch, and a class named Switch is implemented in the Xamarin.Forms.Core library. In the individual renderers for the three platforms, this Switch is mapped to a UISwitch on the iPhone, a Switch on Android, and a ToggleSwitch on Windows Phone.

Xamarin.Forms.Core also contains a class named Slider for displaying a horizontal bar that the user manipulates to choose a numeric value. In the renderers in the platform-specific libraries, this is mapped to a UISlider on the iPhone, a SeekBar on Android, and a Slider on Windows Phone.

This means that when you write a Xamarin.Forms program that has a Switch or a Slider, what’s actually displayed is the corresponding object implemented in each platform.

Source of Information : Creating Mobile Apps with Xamarin.Forms

No comments: