How to implement the new PrismApplication to replace the Bootstrapper class

TomTomB picture TomTomB · Dec 20, 2017 · Viewed 13.2k times · Source

Since the Bootstrapper Class is obsolete with Prism 7 I would like to change my C# WPF App using the PrismApplication Class.

Does anybody know how to refactor a Prism 6 App using the Bootstrapper : UnityBootstrapper to the new PrismApplication?

I´m asking because the documentation regarding those pre-releases is pretty limited and I am not the best in understanding what I need to do from just looking at the Prism source code.

Answer

Haukinger picture Haukinger · Dec 20, 2017

It depends on what your bootstrapper does, but Prism.Unity.PrismApplication has similar methods to override, so you should be able to copy the code over from the bootstrapper. Probably you only need RegisterTypes and CreateShell. Remember to update App.xaml to change the type of your application...

App.xaml should be something like this:

<prism:PrismApplication x:Class="WpfApp1.App"
                        x:ClassModifier="internal" 
                        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                        xmlns:prism="http://prismlibrary.com/"/>

and for completeness' sake, App.xaml.cs:

internal partial class App
{
    protected override void RegisterTypes(IContainerRegistry containerRegistry)
    {
        throw new NotImplementedException();
    }

    protected override Window CreateShell()
    {
        throw new NotImplementedException();
    }
}