本文介绍了如何实现新的 PrismApplication 来替换 Bootstrapper 类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于 Bootstrapper 类在 Prism 7 中已过时,我想使用 PrismApplication 类更改我的 C# WPF 应用程序.

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

有人知道如何使用 Bootstrapper : UnityBootstrapper 将 Prism 6 应用程序重构为新的 PrismApplication 吗?

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

我之所以这么问,是因为有关这些预发布版本的文档非常有限,而且我仅通过查看 Prism 源代码就不太了解我需要做什么.

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.

推荐答案

这取决于你的引导程序做什么,但是 Prism.Unity.PrismApplication 有类似的方法来覆盖,所以你应该能够从引导程序复制代码.可能您只需要RegisterTypesCreateShell.请记住更新 App.xaml 以更改应用程序的类型...

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 应该是这样的:

<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/"/>

为了完整起见,App.xaml.cs:

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

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

这篇关于如何实现新的 PrismApplication 来替换 Bootstrapper 类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 12:01