2

我在 Prism.Wpf 7.0 中尝试一个 hello world 程序。我试图从 app.config 文件加载一个模块。这是行不通的。我使用的是PrismApplication因为UnityBootstrapper在 Prism.Wpf 7.0 中已过时。

我的 app.config 为..

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="modules" type="Prism.Modularity.ModulesConfigurationSection, Prism.Wpf" />
  </configSections>
  <startup>
  </startup>
  <modules>
    <module assemblyFile="ModuleA.dll" moduleType="ModuleA.ModuleAModule, ModuleA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" moduleName="ModuleAModule" startupLoaded="True" />
  </modules>
</configuration>

我的 app.xaml.cs 作为..

internal partial class App : PrismApplication
    {
        //ShellView _tempShellView;
        protected override Window CreateShell()
        {
            var _tempShellView = Container.Resolve<ShellView>();
            var _tempDataContext = Container.Resolve<ShellViewModel>();
            _tempDataContext.ShellWindowClose = new Action(() => _tempShellView.Close());
            _tempShellView.DataContext = _tempDataContext;
            _tempDataContext.Initialize();

            return _tempShellView;
        }

        protected override void InitializeShell(System.Windows.Window shell)
        {
            shell.Show();
        }

        protected override IModuleCatalog CreateModuleCatalog()
        {
            return new ConfigurationModuleCatalog();
            //return  new DirectoryModuleCatalog() {  ModulePath = Environment.CurrentDirectory };
        }
    }

我的 ModuleAModule.cs 作为..

public class ModuleAModule : IModule
    {
        IRegionManager _regionManager;

        public ModuleAModule(RegionManager regionManager)
        {
            _regionManager = regionManager;
        }

        public void Initialize()
        {
            _regionManager.RegisterViewWithRegion("ContentRegion", typeof(ViewA));
        }
    }

当我使用 6.3 尝试此代码时,它正在运行UnityBootstrapper。在这个 Prism.Wpf 7.0 上需要帮助

4

1 回答 1

0

伙计们感谢查看我的帖子..不,我有工作代码..这是我的github 示例代码

于 2018-03-27T21:43:13.690 回答