Build your first Xamarin.Forms App

Watch this video and follow along to create your first mobile app with Xamarin.Forms.

Step-by-step instructions for Windows

Follow these steps along with the video above:

  1. Choose File > New > Project... or press the Create new project... button, then select Visual C# > Cross-Platform > Mobile App (Xamarin.Forms):

    Mobile App (Xamarin.Forms)

  2. Ensure Android and iOS are selected, with .NET Standard code sharing:

    Android and iOS, with .NET Standard

  3. Wait until the NuGet packages are restored (a "Restore completed" message will appear in the status bar).

  4. Launch Android emulator by pressing the debug button (or the Debug > Start Debugging menu item).

  5. Edit MainPage.xaml, adding this XAML before the end of the </StackPanel>:

    <Button Text="Click Me" Clicked="Button_Clicked" />
    
  6. Edit MainPage.xaml.cs, adding this code to the end of the class:

    int count = 0;
    void Button_Clicked(object sender, System.EventArgs e)
    {
        count++;
        ((Button)sender).Text = $"You clicked {count} times.";
    }
    
  7. Debug the app on Android:

    Android app

    Tip

    It is possible to build and debug the iOS app from Visual Studio with a networked Mac computer. Refer to the setup instructions for more information.

Step-by-step instructions for Mac

Follow these steps along with the video above:

  1. Choose File > New Solution... or press the New Project... button, then select Multiplatform > App > Blank Forms App:

    Blank Forms App

  2. Ensure Android and iOS are selected, with .NET Standard code sharing:

    Android and iOS, with .NET Standard

  3. Restore NuGet packages, by right-clicking on the solution:

    Android app

  4. Launch Android emulator by pressing the debug button (or Run > Start Debugging).

  5. Edit MainPage.xaml, adding this XAML before the end of the </StackPanel>:

    <Button Text="Click Me" Clicked="Handle_Clicked" />
    
  6. Edit MainPage.xaml.cs, adding this code to the end of the class:

    int count = 0;
    void Handle_Clicked(object sender, System.EventArgs e)
    {
        count++;
        ((Button)sender).Text = $"You clicked {count} times.";
    }
    
  7. Debug the app on Android:

    Android app

  8. Right-click to set iOS to the Startup Project:

    Set the startup project to iOS

  9. Debug the app on iOS:

    iOS app

You can download the completed code from the samples gallery or view it on GitHub.

Next Steps