How to Create a Simple ListView App in Xamarin.Forms

Xamarin.Forms
img_xamarin

Any of the mobile application is not worthy without “Listview”.
Listview is very common control in the mobile application. It is responsible for displaying collection of items on the screen. Each item contained inside the listview will be in the separate cell. By default listview will use the built in “TextCell” template and render a single line of text.

The following demo will show you how to create and use a listview in the xamarin.Forms

Create a new solution and name it as “ListVIewXamarinForms”.

xf4.1

Now we have to create a listview and add some items in to the listview for display purpose
Open the ListviewXamarinForms.cs file and make the following changes.
Create a list and name it as “item” The following code will create a list.

The list is being created but still there is nothing to display so we had to add some content to the list as follows.

Now we have to create a listview add the following code to create a listview.

After creation of the list we have to assign the data to the listview . We have to use the previously created list here add the following code to assign the list to listview.

Now we have finished with the listview all we have to do just add the listview control to the layout

Run your application and it will look like below.

xf4.2

xf4.3

The same code will work on Android as well as iOS both. The simulator will look like above on both the platform.

If you like this tutorial then you can download full copy of the code from github

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">