Tag : xamarinforms

Child control Event handling in Listview using Xamarin.Forms

We can add child controls to Listview in Xamarin.Forms. In order to see the child control in action we will take an example. Let’s display a list of data in the Listview and perform delete option on the list data per row basis.

Since we need to add multiple columns in the list view, we need to use the DataTemplate to define the custom view. Let’s use a model class to assign the data to the custom view.

We will use XAML to design a Listview

In the above XAML, we have used the StackLayout as the parent container for the child views. It contains a Label and a Listview. UI Control is ready.

Time to add event to the child control
We will replace the Button control in the above XAML with the following line

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

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.


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


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.

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

What’s new in Xamarin.Forms 1.3 : Inherited App Class

With the new release of Xamarin.Forms 1.3 version, the App Class has its new Avatar.

The Older version of App Class was just a class with static methods.

Unlike the older version, the new version is an inherited class from the Xamarin.Forms.Application class.

Summary of improvements

Addition of new life cycle events :

We can handle separate events during different phases of app interaction life cycle.

  • onStart :- Allows us to handle the app start up. We can write code here to get executed during on app start up.
  • onSleep :- We can write code here to get executed while app in entering into the sleep/minimize mode.
  • onResume :- Code can be executed after the app regains the focus.

Self static object :
Application class uses a static instance of its own, which is named as Current. It can be accessed through out the application.

MainPage attribute :
MainPage is an attribute of the Application Class of type ContentPage. As the name suggest, we can assign the root page of the application to this attribute.

Properties :
Not to be confused, this is an attribute of the Application Class. It contains the Dictionary object. We can read/write application level global variables to it for further use in a Key and Value pair format.

Resources :
Application Class Resources attribute can store the resources for application use. This attribute is of type ResourceDictionary.We can add Implicit Styles (in XAML) and Key Value pair strings to it.

Happy coding 🙂

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

%d bloggers like this: