Development Of Native UI Mobile Applications Using Xamarin Forms

Development Of Native UI Mobile Applications Using Xamarin Forms

A- Introduction

Xamarin.Form is a framework which allows developers to rapidly create cross-platform user interfaces. Applications developed using such framework can be shared across various platforms which include Android, iOS, Windows, and Windows Phone. Such UI is rendered using native controls of the target platform. This implies that Xamarin.Forms applications help in retaining the apt look and feel of every platform.

Xamarin.Forms applications are build in the same way as traditional cross-platform applications are created. Applications which are developed using Xamarin.Forms are able to use API’s or features of platforms such as Tiles on Windows, StoreKit, CoreMotion, PassKit on iOS; NFC and Google Play Services on Android. Some common approach to developing applications using Xamarin.Forms is to use Portable Libraries or Shared Projects first in order to use the shared code and then creating a platform specific application which will consume the shared code.

B- Creating User Interfaces In Xamarin.Forms

Popularly there are two techniques to create user interfaces in Xamarin.Forms. First is to create user interfaces entirely with C# source code, the second is to use XAML (Extensible Application Markup Language). XAML is a declarative markup language which helps in describing user interfaces.

C- How to launch the Initial Xamarin.Forms Page on Each Platform?

The initialization steps to define Xamarin.Forms vary from platform to platform and is discussed in the following sections.

C1: iOS

For launching initial Xamarin.Forms page in iOS, the platform project must include the AppDelegate class that inherits from the Xamarin.Forms.Platform.iOS.FormsApplicationDelegateclass. The same is displayed below in the code:

FinishedLoading override initializes the Xamarin.Forms framework by calling the Init method. This allows iOS-specific implementation of Xamarin.Forms which can be loaded in the application before the root view controller is set by the call to the LoadApplication method.

public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
   public override bool FinishedLaunching(UIApplication app, NSDictionary options)
     global::Xamarin.Forms.Forms.Init ();
     LoadApplication (new App ());
     return base.FinishedLaunching (app, options);

C2: Android

Launching the initial Xamarin.Forms page in Android includes code which creates an Activity with theMainLauncher attribute. It also comprises of activity inheriting from the FormsApplicationActivity class, as demonstrated in the following code example:

Call Init method for OnCreate override initializing the Xamarin.Forms framework. This allows Android-specific implementation of Xamarin.Forms before the Xamarin.Forms application is loaded.

namespace HelloXamarinFormsWorld.Android
   [Activity(Label = "HelloXamarinFormsWorld", MainLauncher = true,
       ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
   public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
       protected override void OnCreate(Bundle bundle)
           Xamarin.Forms.Forms.Init(this, bundle);
           LoadApplication (new App ());

C3: Windows Phone 8 (WinRT)

In Windows Runtime applications, by using Init method you can initialize the Xamarin.Forms framework which gets invoked from the Appclass:

Xamarin.Forms.Forms.Init (e);

if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)

Above code allows Windows Phone-specific implementation of Xamarin.Forms to be loaded in the application. Later, from the MainPage class, you can launch the Xamarin.Forms page as mentioned below in the code:

LoadApplication method loads the Xamarin.Forms application.

public partial class MainPage
   public MainPage()
     this.NavigationCacheMode = NavigationCacheMode.Required;
     this.LoadApplication(new HelloXamarinFormsWorld.App());

C4: Xamarin.Forms 2.0 for Windows 10

Xamarin 4 brought with it Xamarin.Forms 2.0. This comes with new features and optimizations, therefore helps in building great native cross-platform mobile apps.Additionally, it has brought features like ListView caching strategies, pinch gestures, and many new properties. These have come as a first public preview of Xamarin.Forms for Windows 10 (UWP) applications. We know that Xamarin.Forms already support Windows Phone and Store targets but the icing on the cake is that Windows 10 introduces a Universal Windows project which targets both desktop and phone platform, therefore, allowing easily target even more devices.

Along with offering support for Windows 10 apps, Xamarin.Forms 2.0 also add a plethora of additional features and awesomeness to your mobile apps.

D- Xamarin.Forms User Interfaces

1. Layouts:

Xamarin.Forms comprise of many layouts for organizing on-screen content. Some of them include RelativeLayout, StackLayout, ScrollView,Grid, AbsoluteLayout. They can be used to create beautiful, responsive user interfaces.

2. Navigation:

Depending on the Page type being used, Xamarin.Forms provide a number of different pages navigation experiences.

3. ListView:

To display, scrolling rows of data Xamarin.Forms provide a list view control. Some new features like pull-to-refresh, separator customization and much more are added to ListView in Xamarin.Forms 1.3 and 1.4.

4. WebView:

By using native web browser control on each platform, Xamarin.Forms can display websites, local resources, and generated Html strings.

5. TableView:

Tableview is similar to a list view. The difference is that rather than designed for long lists of data it is meant for data-entry-style screens majorly for scrolling controls or simple scrolling menus.

6. Text:

For presenting and receiving text Xamarin.Forms offer several views. These Text views can be formatted and customized for specific platforms.

Various other Xamarin.Forms user interfaces are maps, styles, gestures, animations.

E- Visual Studio Now Includes Xamarin

Developers can design incredible UIs for iOS and Android applications without leaving Visual Studio. Developers can easily and freely avail Xamarin in all the editions of Visual Studio 2015, right from Community to Enterprise.You can use the latest version of Visual Studio 2015 and the latest release of Xamarin in order to access Xamarin for free. Xamarin App Development Services will be freely available in widely available Visual Studio Community Edition which is free for open source projects, academic research, and individual developers. With no limits on app size, you can develop and publish native apps for iOS and Android with C# or F# from directly within Visual Studio.

F- Adieu

The knowledge-base is not tight instead, there are lot many findings, supportive learnings and research done on this topic of Xamarin Forms. I have tried to highlight some of them on Xamarin Forms. With my blogs on Xamarin, I am trying focus on the latest things that can help you in the field of cross-platform app development. Do give me suggestions where can our next blog on Xamarin head to!

Don’t miss to check out – Cross Platform App Development – A good choice for enterprises?

References: blog.xamarin, developer.xamarin

The following two tabs change content below.
Rachit Agarwal

Rachit Agarwal

Director and Co-Founder at Algoworks Technologies
Rachit is leading the mobility business development function, mobility strategy and consulting practice at Algoworks. He is an expert of all mobile technologies and has experience in managing teams involved in the development of custom iPhone/iPad/Android apps.
Rachit Agarwal

Latest posts by Rachit Agarwal (see all)

Rachit AgarwalDevelopment Of Native UI Mobile Applications Using Xamarin Forms