Getting started with Xamarin

  • Xamarin is an app platform for building Android and iOS apps with .NET and C#.
  • Xamarin is Free, Cross-platform and Open source.

Steps to Create Xamarin.Forms project

Step 1: Download and Install Visual Studio Community 2019 Edition and during installation, select the Mobile development with .NET workload.

Step 2: Configure Android device or emulator. After installing Visual Studio, configure a Android device for development or create an Android emulator.

Step 3: Open Visual Studio 2019 and Select Create a new project

Step 4: Select Mobile from the Project type drop-down and Select the Mobile App (Xamarin.Forms) template and click Next

Step 5: Enter project name and click Create

Step 6: Select the Blank template, ensure Android and iOS are selected, and click OK

Now the Project will be created. Now let’s add some code to the blank project and run the project.

Add the below code snippet inside StackLayout in MainPage.xaml file.

 <Label x:Name="label"
               Text="Hello World"
               HorizontalOptions="Center" />

 <Button Text="Rotate Text!"
                Clicked="OnButtonClicked" />

Now add the below button Click event code in MainPage.xaml.cs file

async void OnButtonClicked(object sender, EventArgs args)
            await label.RelRotateTo(180, 1000);

Now connect your Android Phone via USB cable to the developer computer and press play icon below menu bar of the IDE or Debug -> Start Debugging or press F5 . Make sure Emulator or Andorid Device is selected. Also make sure you allow “Install via USB” from the device when it popups up in the device. Now the app will be installed in your mobile device.



Learn more about Xamarin.Forms, Xamarin.Android, Xamarin.iOS in our upcoming Xamarin blog articles.

Happy Learning!