ListView Control In Xamarin.Forms Application For Android And UWP

Before reading this article, please go through the article How To Create And Use XAML Content Page In Xamarin.Forms Application For Android And Universal Windows Platform.

After reading this article, you will learn how to use ListView control in Xamarin Forms Application for Android and Universal Windows Platform with XAML and Visual C# in cross platform application development.

The important tools are given below, which are required to develop UWP.

  1. Windows 10 (Recommended).
  2. Visual Studio 2015 Community Edition (It is a free software available online).
  3. Using Visual Studio 2015 Installer, enable Xamarin (Cross Platform Mobile development and C#/.NET, while installing/modifying Visual Studio 2015.

Now, we can discuss step by step app development.

Step 1

Open Visual Studio 2015 -> Start -> New Project-> select Cross-Platform (under Visual C#-> Blank app (Xamarin.Forms Portable)-> Give the suitable name for your app (XamFormListView) ->OK.

.NET

Step 2

Now, create project “XamFormListView_Droid”. Choose Target and minimum platform version for your Universal Windows Project and create a project “XamFormListView_UWP”.

.NET

.NET

Step 3

Afterwards, Visual Studio creates six projects and displays Getting Started.XamarinPage. Now, we have to update Xamarin.Forms Reference for the portable project and XamFormListView_Droid project.

(Please refer How To Create And Use XAML Content Page In Xamarin.Forms Application For Android And Universal Windows Platform).

Step 4

Add XAML page for ListView control demo. Right click XamFormListView(Portable) project. Select ADD-> NewItem. 

.NET

Select -> CrossPlatform-> FormXamlPage-> Give the relevant name.

.NET

Step 5

Add ListView control tag with ItemTemplate and Label in ListViewDemo.xaml.

.NET

Step 6

In ListViewDemo.xaml.cs, add the code, mentioned below for ListView items.

.NET

Step 7

Open (double click) the file App.cs in the Solution Explorer-> XamFormListView(portable) and set the Root page. 

.NET

Step 8

We will test Android and UWP. Thus, we can set the Multiple Startup Projects as XamFormListView.Droid and XamFormListView.UWP (Universal Windows). 

.NET

Step 9

Change the Configuration Manager settings. Go to Build -> Configuration Manager, uncheck all the build and deploy options to the iOS, Windows, WinPhone, check the Droid and UWP.

.NET

Step 10

Deploy your app in the local machine and the output of the XamFormListView app is shown below.

.NET

Summary

Now, you have successfully created and tested ListView control in Xamarin.Forms Application for Cross Platform Application Development , using Visual C# and Xamarin.