Customizing Listview display in Xamarin

As the usual behavior of ListView to display the items in a list and it contains a single column. The ItemSource property of Listview accepts the list of data to be displayed and render the same on screen.

The code for a simple list to display the Students of a class would like as in the following pic.

ListViewInXamarinForms

Now let’s customize this ListView in a way to display the Student Name along with the Class and School they belongs to.

ListViewItem

As in the image above, the data contains a single record. So to accommodate the data in a single record, Let’s create a Student model class.

In order to customize the ListView display, we need to override the ViewCell class.

We are done with the Model and the inherited ViewCell class i.e. StudentCell. We will use the ItemTemplate attribute of ListView to assign the StudentCell class.

Let’s run the app to see the new ListView.

Happy coding 🙂

Categories: Android, Cross Platform Mobile App, iOS, Visual Studio, Windows Phone, Xamarin

Leave a Reply

%d bloggers like this: