Using the Visual Studio integrated development environment and the C# programming language, we will develop a cross-platform mobile application for a phone book containing a list of contacts.
Start
Launch the Visual Studio integrated development environment.
Create a new project: Visual C# > Cross-Platform > Mobile App (Xamarin.Forms).
Name the project: Phone Book 2.0.
Add additional packages to the project by installing Newtonsoft.Json from: Tools > NuGet Package Manager > Package Manager Console, by running the following command in the console:
Add a new class ViewModel.cs containing the following code fragment:
MainPage.xaml
The MainPage.xaml file contains the source code for the application's user interface design and is written in XAML. Copy (Ctrl+C) and paste (Ctrl+V) the fragment below into your application.
MainPage.xaml.cs
The MainPage.xaml.cs file contains the source code for the application's business logic and is written in C#. Copy (Ctrl+C) and paste (Ctrl+V) the fragment below into your application.
AddPage.xaml
Add a new page AddPage.xaml. Copy (Ctrl+C) and paste (Ctrl+V) the fragment below into your application.
AddPage.xaml.cs
Open the file AddPage.xaml.cs. Copy (Ctrl+C) and paste (Ctrl+V) the fragment below into your application.
Demo
Run the application from the menu: Debug > Start Debugging or by pressing the F5 key.
Fig. 2.64. Demonstration of the cross-platform mobile phone book application