-
-
Notifications
You must be signed in to change notification settings - Fork 144
Bootstrapper
Antony Male edited this page Apr 22, 2014
·
15 revisions
The bootstrapper is responsible for bootstrapping your application. It configures the IoC container, creates a new instance of your root ViewModel and displays it using the WindowManager
. It also provides various other functions, described below.
The bootstrapper comes in two flavoures: BootstrapperBase<TRootViewModel>
, which requires you to configure the IoC container yourself, and Bootstrapper<TRootViewModel>
, which uses Stylet's built-in IoC container, StyletIoC.
Example bootstrapper, using StyletIoC:
class Bootstrapper : Bootstrapper<MyRootViewModel>
{
protected override void ConfigureIoC(IStyletIoCBuilder builder)
{
// Bind your own types. Concrete types are automatically self-bound.
builder.Bind<IMyInterface>().To<MyType>();
}
protected override void OnStartup(object sender, StartupEventArgs e)
{
// Called on Application.Startup
}
protected override void OnExit(object sender, EventArgs e)
{
// Called on Application.Exit
}
protected override void OnUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
// Called on Application.DispatcherUnhandledException
}
}
If you want to use another IoC container with Stylet, derive from BootstrapperBase<TRootViewModel>
, and Configure
, GetInstance
, GetAllInstances
, and BuildUp
. For an example, see NinjectBootstrapper.
- Introduction
- Quick Start
- Bootstrapper
- ViewModel First
- Actions
- The WindowManager
- MessageBox
- The EventAggregator
- PropertyChangedBase
- Execute: Dispatching to the UI Thread
- Screens and Conductors
- BindableCollection
- Validation using ValidatingModelBase
- StyletIoC
- The ViewManager
- Listening to INotifyPropertyChanged
- Design Mode Support
- Logging
- Misc