MVVMbasics Logo

mobilemotion.eu Logo


Back to Class Reference home page


MVVMbasics
Class BaseApplication

Windows.UI.Xaml.Application | System.Windows.Application | System.Windows.Application | Xamarin.Forms.Application
  extended by MVVMbasics.BaseApplication
 

 
public class BaseApplication : Windows.UI.Xaml.Application | System.Windows.Application | System.Windows.Application | Xamarin.Forms.Application

Base Application class the phone application can be derived from.


Property Summary
public ServiceRegistry Services { get; private set; }
Simple IoC container that can be used to register MVVM services that are used within Viewmodels.
public ServiceLocator ServiceLocator { get; private set; }
ServiceLocator instance that can be used throughout the application. Services should be registered to it in the BaseApplication's constructor. This ServiceLocator instance will be passed on to all Viewmodels.
Deprecated. Use App.Services or any 3rd party IoC container instead.
 
Constructor Summary
public  BaseApplication()
Constructor. Registers a PhoneApplicationService event to the application that contains implementations of the Launching, Activated, Deactivated, and Closing events.
 
Method Summary
protected internal virtual object  Resolve(Type type)
Method that instantiates Viewmodels and resolves service references. Override this method to use MVVMbasics with any IoC container.
virtual void  OnLaunching(object sender, LaunchingEventArgs e)
Method that is executed when the application is launching (eg, from Start), but not when the application is reactivated.
virtual void  OnActivated(object sender, ActivatedEventArgs e)
Method that is executed when the application is activated (brought to foreground), but not when the application is first launched.
virtual void  OnDeactivated(object sender, DeactivatedEventArgs e)
Method that is executed when the application is deactivated (sent to background), but not when the application is closing.
virtual void  OnClosing(object sender, ClosingEventArgs e)
Method that is executed when the application is closing (eg, user hit Back), but not when the application is deactivated.
 
Constructor Detail

BaseApplication

public BaseApplication()

Constructor. Registers a PhoneApplicationService event to the application that contains implementations of the Launching, Activated, Deactivated, and Closing events.

Method Detail

Resolve

protected internal virtual object Resolve(Type type)

Method that instantiates Viewmodels and resolves service references. Override this method to use MVVMbasics with any IoC container.

Parameters:

type - Type of the class to be resolved and instantiated.

Returns:

Instance of the desired type.


OnLaunching

public virtual void OnLaunching(object sender, LaunchingEventArgs e)

Method that is executed when the application is launching (eg, from Start), but not when the application is reactivated.
Subclasses can override this method to run custom code when the application is launching.


OnActivated

public virtual void OnActivated(object sender, ActivatedEventArgs e)

Method that is executed when the application is activated (brought to foreground), but not when the application is first launched. If the application is reactivated from tombstoning, sets a flag to the currently active view to indicate that ViewState must be set to Awakaned.
Subclasses can override this method to run custom code when the application is activated, but should not forget to add a call to base.OnActivated(sender, e).


OnDeactivated

public virtual void OnDeactivated(object sender, DeactivatedEventArgs e)

Method that is executed when the application is deactivated (sent to background), but not when the application is closing.
Subclasses can override this method to run custom code when the application is deactivated.


OnLaunching

public virtual void OnClosing(object sender, ClosingEventArgs e)

Method that is executed when the application is closing (eg, user hit Back), but not when the application is deactivated.
Subclasses can override this method to run custom code when the application is closing.