Creating a Xamarin.Forms Project
In this chapter, we will discuss how to consume the NuGet package which we have created and published to a private NuGet feed. So, first we will create a Xamarin.Forms project. We need to first understand what is Xamarin.Forms.
Xamarin.Forms is a framework that allows developers to rapidly create crossplatform user interfaces.
Xamarin.Forms is a cross-platform natively backed UI toolkit abstraction that allows developers to easily create user interfaces that can be shared across Android, iOS, Windows, and Windows Phone.
The user interfaces are rendered using the native controls of the target platform, allowing Xamarin.Forms applications to retain the appropriate look and feel for each platform.
To start Xamarin.Forms, we need some additional features in Visual Studio 2015. Let us modify your Visual Studio 2015 and make sure the following cross-platform mobile development option is selected.
Once the installation is finished, let us update the Xamarin by selecting Tools → Options…
Scroll down and expand Xamarin in the left pane and then select Other. On top right hand corner of the dialog box, click on Check Now to see if updates are available.
You can see that updates are available, let us click on the Download button to start downloading. Once downloading is finished, you will be notified to install the updates.
Let us now open the Visual studio again and select the File → New → Project… menu option.
In the left pane, select the Visual C# → Cross-Platform template and in the middle pane, select Blank Xaml App (Xamarin.Forms Portable). Enter the name in the Name field and click OK.
Select the Target Version and the Minimum Version and click OK.
You will see a series of projects; at the top we have the PCL library which will be shared among all platforms like Android, iOS, UWP, Windows 8.1, and Windows Phone 8.1.
Here, we will focus on the PCL library and will bring some code here. Let us expand the code.
In this Xamarin.Forms template, you can see the generic App.xaml and MainPage.xaml, uses Xamarin.Forms XAML framework which works across these platforms.
We need to import our codes and we also need the private NuGet feed we set up in the last chapter.
Let us now open the NuGet Package Manager. Click on the wheel next to the Package source dropdown list.
We need to add our private feed here, let us click on the plus (+) button.
You will see that another checkbox is added in the Available package sources section, let us specify a name and source path and click OK.
Let us now go to the Browse tab and select PrivateSource from the Package source dropdown list and you will see the StringLibrary NuGet package. Select StringLibrary and click Install.
Click OK and you will see one error.
We can’t use library with .NETPortable profile version 259, we will be fixing this error in the next chapter.