Installing Xamarin
How to set up Visual Studio and Xamarin to start building mobile apps with .NET.
Installing Xamarin on Windows
Step-by-step instructions
Xamarin can be installed as part of a new Visual Studio 2019 installation, with the following steps:
- Download Visual Studio 2019 Community, Visual Studio Professional, or Visual Studio Enterprise from the Visual Studio page (download links are provided at the bottom).
- Double-click the downloaded package to start installation.
- Select the Mobile development with .NET workload from the installation screen:
- When you are ready to begin Visual Studio 2019 installation, click the Install button in the lower right-hand corner:
Use the progress bars to monitor the installation:
- When Visual Studio 2019 installation has completed, click the Launch button to start Visual Studio:
Build your first Xamarin.Forms App
Step-by-step instructions for Windows
Follow these steps along with the video above:
- Choose File > New > Project… or press the Create new project… button:
- Search for “Xamarin” or choose Mobile from the Project type menu. Select the Mobile App (Xamarin.Forms) project type:
- Choose a project name – the example uses “AwesomeApp”:
- Click on the Blank project type and ensure Android and iOS are selected:
- Wait until the NuGet packages are restored (a “Restore completed” message will appear in the status bar).
- New Visual Studio 2019 installations won’t have an Android emulator configured. Click the dropdown arrow on the Debug button and choose Create Android Emulator to launch the emulator creation screen:
- In the emulator creation screen, use the default settings and click the Create button:
- Creating an emulator will return you to the Device Manager window. Click the Start button to launch the new emulator:
- Visual Studio 2019 should now show the name of the new emulator on the Debug button:
- Click the Debug button to build and deploy the application to the Android emulator:
Customize the application
The application can be customized to add interactive functionality. Perform the following steps to add user interaction to the application:
- Edit MainPage.xaml, adding this XAML before the end of the
</StackLayout>
: XAML
<Button Text="Click Me" Clicked="Button_Clicked" />
Edit MainPage.xaml.cs, adding this code to the end of the class: C#
int count = 0; void Button_Clicked(object sender, System.EventArgs e) { count++; ((Button)sender).Text = $"You clicked {count} times."; }
- Debug the app on Android:
Note
The sample application includes the additional interactive functionality that is not covered in the video.