The Application Bootstrapper

Context

Any application needs to start up somehow. Application bootstrapping is the process of initializing the application and displaying the root view model.

Bootstrapping an Application

Bootstrapping an application in the DevForce Application Framework is accomplished by means of a bootstrapper class created as a static resource in the applications’s App.xaml. The bootstrapper class is created by extending the generic class FrameworkBootstrapper<TRootModel>.

The bootstrapper needs the type of the ViewModel that represents the first screen the user should see. The ViewModel must be decorated with the proper MEF export attribute in order for the bootstrapper to create an instance through MEF.

public class AppBootstrapper : FrameworkBootstrapper<MainViewModel>
{
    // Add additional logic if required. 
}

Then all that needs to be done is to create a static resource from the bootstrapper:

<Application x:Class="SampleApplication.App" 
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:app="clr-namespace:SampleApplication;assembly=SampleApplication.SL">
    <Application.Resources>
        <app:AppBootstrapper x:Key="Bootstrapper" />
    </Application.Resources>
</Application>

Last edited Dec 14, 2011 at 6:58 AM by marcelgood, version 6

Comments

No comments yet.