Share via


Application Class

Definition

Class that represents a cross-platform mobile application.

public class Application : Xamarin.Forms.Element, Xamarin.Forms.IApplicationController, Xamarin.Forms.IElementConfiguration<Xamarin.Forms.Application>
type Application = class
    inherit Element
    interface IApplicationController
    interface IElementConfiguration<Application>
Inheritance
System.Object
Application
Implements

Remarks

The Application class is the core of a Xamarin.Forms application. It sets the root page of the application, persists primitive type data across invocations of the application in the Properties dictionary, and provides events to respond to pushing and popping of modal views. Visual studio creates this class for the developer in the appropriate project in a new Xamarin.Forms solution.

Both Visual Studio for Mac and Visual Studio create a XAML and a code-behind file for the application when the developer creates a new Xamarin.Forms solution. The following example shows a typical Application class, with an entry in its resource dictionary.

<Application xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="App1.App">
<Application.Resources>
<Color x:Key="ButtonBackgroundColor">Red</Color>
</Application.Resources>
</Application>
public partial class App : Application
{
    public App()
    {
        InitializeComponent();

        MainPage = new MainPage();
    }

    protected override void OnStart()
    {
        // Handle when your app starts
    }

    protected override void OnSleep()
    {
        // Handle when your app sleeps
    }

    protected override void OnResume()
    {
        // Handle when your app resumes
    }
}

Constructors

Application()

Initializes a new Application instance.

Properties

AppLinks

Gets the object that developers use to register or unregister application links.

AutomationId

Gets or sets a value that allows the automation framework to find and interact with this element.

(Inherited from Element)
BindingContext

Gets or sets object that contains the properties that will be targeted by the bound properties that belong to this BindableObject.

(Inherited from BindableObject)
ClassId

Gets or sets a value used to identify a collection of semantically similar elements.

(Inherited from Element)
Current

Gets the current application.

Dispatcher
EffectControlProvider

For internal use by the Xamarin.Forms platform.

(Inherited from Element)
Effects

A list of the effects that are applied to this item.

(Inherited from Element)
Id

Gets a value that can be used to uniquely identify an element through the run of an application.

(Inherited from Element)
LogicalChildren

For internal use by the Xamarin.Forms platform.

(Inherited from Element)
LogWarningsToApplicationOutput
Obsolete.

Gets or sets whether runtime warnings are sent to the application's output.

MainPage

Gets or sets the root page of the application.

NavigationProxy

For internal use by the Xamarin.Forms platform.

PanGestureId

For internal use by the Xamarin.Forms platform.

Parent

Gets or sets the parent element of the element.

(Inherited from Element)
ParentView
Obsolete.

Gets the element which is the closest ancestor of this element that is a VisualElement.

(Inherited from Element)
Platform
Obsolete.
(Inherited from Element)
Properties

Gets a dictionary of persistent properties for this Application object.

RealParent

For internal use by the Xamarin.Forms platform.

(Inherited from Element)
RequestedTheme
Resources

Gets or sets the resource dictionary for this Application object.

StyleId

Gets or sets a user defined value to uniquely identify the element.

(Inherited from Element)
UserAppTheme

Methods

ApplyBindings()

Apply the bindings to BindingContext.

(Inherited from BindableObject)
CleanUp()
ClearCurrent()

For internal use by the Xamarin.Forms platform.

ClearValue(BindableProperty)

Clears any value set by SetValue for property.

(Inherited from BindableObject)
ClearValue(BindablePropertyKey)

Clears any value set by SetValue for the property that is identified by propertyKey.

(Inherited from BindableObject)
CoerceValue(BindableProperty) (Inherited from BindableObject)
CoerceValue(BindablePropertyKey) (Inherited from BindableObject)
Descendants()

For internal use by the Xamarin.Forms platform.

(Inherited from Element)
EffectIsAttached(String)

For internal use by the Xamarin.Forms platform.

(Inherited from Element)
FindByName(String)

Returns the element that has the specified name.

(Inherited from Element)
GetValue(BindableProperty)

Returns the value that is contained in the BindableProperty.

(Inherited from BindableObject)
GetValues(BindableProperty, BindableProperty, BindableProperty)
Obsolete.

For internal use by the Xamarin.Forms platform.

(Inherited from BindableObject)
GetValues(BindableProperty, BindableProperty)
Obsolete.

For internal use by the Xamarin.Forms platform.

(Inherited from BindableObject)
IsApplicationOrNull(Element)

For internal use by the Xamarin.Forms platform.

IsSet(BindableProperty)

Returns true if the target property exists and has been set.

(Inherited from BindableObject)
On<T>()

Returns the platform-specific instance of this Application, on which a platform-specific method may be called.

OnAppLinkRequestReceived(Uri)

App developers override this method to respond when the user initiates an app link request.

OnBindingContextChanged()

Invoked whenever the binding context of the element changes. Implement this method to add class handling for this event.

(Inherited from Element)
OnChildAdded(Element)

Invoked whenever the ChildAdded event needs to be emitted. Implement this method to add class handling for this event.

(Inherited from Element)
OnChildRemoved(Element, Int32) (Inherited from Element)
OnChildRemoved(Element)
Obsolete.

Invoked whenever the ChildRemoved event needs to be emitted. Implement this method to add class handling for this event.

(Inherited from Element)
OnParentSet()

Throws System.InvalidOperationException.

OnPropertyChanged(String)

Method that is called when a bound property is changed.

(Inherited from Element)
OnPropertyChanging(String)

Call this method from a child class to notify that a change is going to happen on a property.

(Inherited from BindableObject)
OnResume()

Application developers override this method to perform actions when the application resumes from a sleeping state.

OnSleep()

Application developers override this method to perform actions when the application enters the sleeping state.

OnStart()

Application developers override this method to perform actions when the application starts.

Quit()

Quits the application.

RemoveBinding(BindableProperty)

Removes a previously set binding.

(Inherited from BindableObject)
RemoveDynamicResource(BindableProperty)

Removes a previously set dynamic resource

(Inherited from Element)
SavePropertiesAsync()

Asynchronously persists the Properties dictionary for the application object.

SendOnAppLinkRequestReceived(Uri)

For internal use by the Xamarin.Forms platform.

SendResume()

For internal use by the Xamarin.Forms platform.

SendSleep()

For internal use by the Xamarin.Forms platform.

SendSleepAsync()

For internal use by the Xamarin.Forms platform.

SendStart()

For internal use by the Xamarin.Forms platform.

SetAppIndexingProvider(IAppIndexingProvider)

For internal use by the Xamarin.Forms platform.

SetBinding(BindableProperty, BindingBase)

Assigns a binding to a property.

(Inherited from BindableObject)
SetCurrentApplication(Application)

For internal use by the Xamarin.Forms platform.

SetDynamicResource(BindableProperty, String)

Sets the BindableProperty property of this element to be updated via the DynamicResource with the provided key.

(Inherited from Element)
SetValue(BindableProperty, Object)

Sets the value of the specified property.

(Inherited from BindableObject)
SetValue(BindablePropertyKey, Object)

Sets the value of the propertyKey.

(Inherited from BindableObject)
SetValueCore(BindableProperty, Object, SetValueFlags)

For internal use by the Xamarin.Forms platform.

(Inherited from BindableObject)
SetValueFromRenderer(BindableProperty, Object)

For internal use by the Xamarin.Forms platform.

(Inherited from Element)
SetValueFromRenderer(BindablePropertyKey, Object)

For internal use by the Xamarin.Forms platform.

(Inherited from Element)
TriggerThemeChanged(AppThemeChangedEventArgs)
UnapplyBindings()

Unapplies all previously set bindings.

(Inherited from BindableObject)

Events

BindingContextChanged

Raised whenever the BindingContext property changes.

(Inherited from BindableObject)
ChildAdded

Occurs whenever a child element is added to the element.

(Inherited from Element)
ChildRemoved

Occurs whenever a child element is removed from the element.

(Inherited from Element)
DescendantAdded

Occurs whenever a child element is added to the elements subtree.

(Inherited from Element)
DescendantRemoved

Occurs whenever a child element is removed from the elements subtree.

(Inherited from Element)
ModalPopped

Event that is raised after a view has been popped modally.

ModalPopping

Event that is raised when a view is modally popped.

ModalPushed

Event that is raised after a view has been pushed modally.

ModalPushing

Event that is raised when a view is modally pushed.

PageAppearing

Event that is raised when a page is about to appear on the screen.

PageDisappearing

Event that is raised when a page is about to disappear from the screen.

PlatformSet
Obsolete.
(Inherited from Element)
PropertyChanged

Raised when a property has changed.

(Inherited from BindableObject)
PropertyChanging

Raised when a property is about to change.

(Inherited from BindableObject)
RequestedThemeChanged

Explicit Interface Implementations

IDynamicResourceHandler.SetDynamicResource(BindableProperty, String)

For internal use by the Xamarin.Forms platform.

(Inherited from BindableObject)
IElementController.SetValueFromRenderer(BindableProperty, Object)

For internal use by the Xamarin.Forms platform.

(Inherited from Element)
INameScope.RegisterName(String, Object)

For internal use only.

(Inherited from Element)

Extension Methods

GetPropertyIfSet<T>(BindableObject, BindableProperty, T)
SetAppThemeColor(BindableObject, BindableProperty, Color, Color)
SetBinding(BindableObject, BindableProperty, String, BindingMode, IValueConverter, String)

Creates and applies a binding to a property.

SetBinding<TSource>(BindableObject, BindableProperty, Expression<Func<TSource,Object>>, BindingMode, IValueConverter, String)
Obsolete.

Creates and applies a binding from an expression.

SetOnAppTheme<T>(BindableObject, BindableProperty, T, T)
FindByName<T>(Element, String)

Returns the instance of type T that has name name in the scope that includes element.

Applies to