As we know smartphones are very useful and a basic requirement of all of the people. Mobile does a lot of work by using different applications and makes people’s life easier.
There are so many platforms in the real world for creating mobile applications. These are some details about some platform to create applications :
These all are different platforms to create mobile applications, however the xamarin provides a platform to create apps using the .NET platform.
What is Xamarin?
Xamarin is a hybrid platform to create android and iOS applications in a single platform. Xamarin is an open-source platform to develop applications for Android, iOS and Windows using C# language and the .NET framework. Visual studio provides a platform to create xamarin applications.
Xamarin is all about the developing the mobile apps using C#(without learning java/kotlin,swift/objective c). Moreover if you are willing to use common UI or you already know xaml then you can use xamarin.forms, that will share the same codebase for business logic as well as UI.
Xamarin provides two approaches to create applications.
Xamarin.forms
Xamarin native
Xamarin.Forms
Xamarin.forms provides a single application for all platforms which is android, ios and windows. Xamarin.forms create a shared user interface for all platforms.
Write cross-platform app with C# using visual studio
Share code with all platforms
Share layout and UI across platforms
Xamarin Native
Xamarin native provides Xamarin.iOS, Xamarin.Android and Windows different libraries to create the application on different platforms. Xamarin native create a platform based user interface for applications.
Write Platform independent code with native look
Native app developers can use .Net APIs with platform specific code.
Xamarin.Forms VS Xamarin Native
Xamarin provides two methods for sharing the code between the cross-platform applications:
Portable Libraries (PCL)
Shared Projects
Why should you choose Xamarin as a Mobile App Development Platform?
Xamarin offers cross platform to create applications in three major platforms(Android, iOS, Windows) and helps to create applications for all types of devices. Xamarin applications share 90% of their code. Xamarin enables sharing code across all platforms.Developer write code in C# and managed on all platforms.
Xamarin is open-source and it supports Microsoft so it's stable. Reuse code in all three types of platform so it will reduce your time and efforts. Single language code will work across all platforms, developers just need to create some platform specific code for some of the features.
Xamarin test cloud is a tool for testing cross platform apps and test cloud enables you to test your application in thousands of devices.
Main Advantage of xamarin application is code reusability, code sharing and compatible with android, iOS and windows app in single application
Xamarin.Forms Hot Reload
Hot reload provides to update controls during the development, not required to load the page again and again.It will preserve navigation and data in the opened page and update UI based on changes.
MVVM pattern
The Model-View-ViewModel (MVVM) pattern helps to present business logic and user interface differently. Developers can easily maintain application code and UI.
Model is a class to encapsulate data throughout the app.
View is User interface, it defines layouts of user interface and each view defines in XAML.
ViewModel Defines all business logic like, create properties, commands, methods.
ViewModel-Binding with views :
There are two way to bind viewmodel in View, For example there is LoginPage:
Using Loginpage.Xaml
<ContentPage ... xmlns:local="clr-namespace:appName">
<ContentPage.BindingContext>
<local:LoginViewModel />
</ContentPage.BindingContext>
... // UI interface
</ContentPage>
Using Loginpage.Xaml.cs
public LoginPage()
{
InitializeComponent();
BindingContext = new LoginViewModel();
}
Supported operating systems for Xamarin tools.
macOs (Visual Studio for Mac)
Windows (Visual Studio IDE)
Installation Guide
Installation and Steps to create application
When you finish downloading Visual studio using the Installation Guide , run the installer. The installation page with tools will load, Select options to which is required for mobile app development(Mobile development with .NET) and if required to create windows application, select configuration for UWP(Universal WIndows Platform). Then click "install".
Start Visual Studio and click on "Create a new project"
Now search ‘xamarin’ and select "Mobile App (Xamarin.Forms)" and on the “Next” Button.
Add application name,location and click on the create button.
On Next Select “Blank” and click on OK button
Visual Studio generated a directory structure for Android and iOS, and if you had installed UWP and selected Windows(UWP) from the above image then it will create for Windows as well. Now click on View from the menu bar and select solution explorer.
After doing all this you will see structure of project like this :
About Author
Need a consultation?
Drop us a line! We are here to answer your questions 24/7