What is New in Xamarin Forms 1.3: Inherited APP Class

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

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

Older version of App Class

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

new version is an inherited class

Summary of improvements

New life cycle events have been added.

We can handle separate events during various phases of an app's interaction life cycle.

  • on Start: Allows us to handle the app start up. We can write code here to be executed during on app start up.

  • on Sleep: We can write code here to be executed when an app is entering into the sleep/minimize mode.

  • on Resume: Code can be executed after the app regains the focus.

Self static object

The Application class uses a static instance of its own that is named as Current. It can be accessed using out the application.

  1. Application.Current 

MainPage attribute

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

  1. // The root page of your application  
  2. MainPage = new ContentPage  
  3. {  
  4.    Content = new StackLayout  
  5.    {  
  6.       VerticalOptions = LayoutOptions.Center,  
  7.       Children = {  
  8.          new Label {  
  9.             XAlign = TextAlignment.Center,  
  10.             Text = "Welcome to Xamarin Forms!"  
  11.          }  
  12.       }  
  13.    }  
  14. }; 


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.

  1. Application.Current.Properties.Add(new KeyValuePair<string, object>("AppOwner""Nirmal")); 


The 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.

  1. Application.Current.Resources.Add("AppCaption""My App"); 

Happy coding.

Similar Articles