English 中文(简体)
Creating a Xamarin.Forms Project
  • 时间:2024-11-05

Creating a Xamarin.Forms Project


Previous Page Next Page  

In this chapter, we will discuss how to consume the NuGet package which we have created and pubpshed 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 apppcations 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.

Cross Platform

Once the installation is finished, let us update the Xamarin by selecting Tools → Options…

Tools

Scroll down and expand Xamarin in the left pane and then select Other. On top right hand corner of the dialog box, cpck on Check Now to see if updates are available.

Check Now

You can see that updates are available, let us cpck 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.

Updates

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 cpck OK.

Blank Xaml App

Select the Target Version and the Minimum Version and cpck OK.

Target Version

You will see a series of projects; at the top we have the PCL pbrary which will be shared among all platforms pke Android, iOS, UWP, Windows 8.1, and Windows Phone 8.1.

Here, we will focus on the PCL pbrary and will bring some code here. Let us expand the code.

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. Cpck on the wheel next to the Package source dropdown pst.

Source

We need to add our private feed here, let us cpck on the plus (+) button.

Plus

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 cpck OK.

Source Path

Let us now go to the Browse tab and select PrivateSource from the Package source dropdown pst and you will see the StringLibrary NuGet package. Select StringLibrary and cpck Install.

Select StringLibrary

Cpck OK and you will see one error.

Error

We can’t use pbrary with .NETPortable profile version 259, we will be fixing this error in the next chapter.

Fixing Advertisements