• Xamarin Forms Cross Platform HelloWorld App for Android and iOS

    by  • May 8, 2017 • Xamarin Cross Platfrom Mobile Apps, Xamarin Mobile App Development, Xamarin.Forms • 0 Comments

    In this post, we’ll into look very basic HelloWorld example of Xamarin.Forms cross platform mobile apps. We’ll create a simple Hello World app using Xamarin Forms which will be cross platform. Later on, we’ll run this app both on Android and iOS, and I’ll show you both apps running on emulators. You’ll notice how easy it is to build cross platform apps with Xamarin Forms.

    First, create a New Project in Visual Studio and from templates category select Cross-Platform and from templates select Cross Platform App.

    01. create a new cross platform xamarin.forms project


    This will bring up another dialog where you have to select App type, UI technology, and code sharing strategy. You can select Blank App, Xamarin Forms, and Portable Class Library (PCL) as shown in the screenshot.

    02. select xamarin.forms template code sharing strategy and ui technology


    Once your solution is created successfully, you’ll notice that it has created four projects. One PCL for cross-platform code, while one for each of the Android, iOS, and UWP apps. Before doing anything else, you need to update your packages from NuGet. For that, right click your solution, select NuGet Package Manager, and then select Xamarin.Forms package and click Install or Update as appropriate in your case.

    03. Open NuGet Package Manager from Solution

    04. Select Xamarin.Forms package and Install









    Now, you need to add code in the MainPage.Xaml file for UI and in MainPage.Xaml.cs for the C# code to run behind the UI. First, I’ll share the XAML for MainPage.Xaml file and then I’ll show you the code for C# file.

    This is very simple code just to show you how we can create cross-platform interface and then bind it with the code behind. It shows you a Label, a Text Box and a Button. On clicking button, it shows the message in the label after reading name from the text box. Now, let me show you the running app in Android and iOS.

    Android App:

    05. hello xamarin forms on android start 06. hello xamarin forms on android after click event









    iOS App:

    07. hello xamarin forms on iOS after click event 07. hello xamarin forms on iOS start










    Now, you might have got good idea how to start building cross-platform apps with Xamarin Forms. Try it out and see what you can build from here on. I’ll be back with more examples. The sample project can be downloaded from Github.

    Best WordPress Themes and Plugins with Great Team and Support!

    Avatar of admin


    GetCodeSnippet.com provides you high quality Microsoft .NET development related articles, tutorials and sample code for ASP.NET, C#, VB.NET, AJAX, WCF, WPF, Web Services, Windows Services, SQL Server and other technologies.

    Leave a Reply