Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
385 views
in Technique[技术] by (71.8m points)

prism - How to implement the new PrismApplication to replace the Bootstrapper class

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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();
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...