我刚开始使用 PRISM,遇到一个我无法解决的异常。
<Window x:Class="Workplace.Shell"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:prism="http://www.codeplex.com/prism"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid Name="Header" prism:RegionManager.RegionName="Header">
</Grid>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
.
using Autofac;
using Prism.Autofac;
using Prism.Modularity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace Workplace
{
class Bootstrapper : AutofacBootstrapper
{
protected override DependencyObject CreateShell()
{
return new Shell();
}
protected override void InitializeShell()
{
base.InitializeShell();
Application.Current.MainWindow = (Window) this.Shell;
Application.Current.MainWindow.Show();
}
protected override void ConfigureModuleCatalog()
{
base.ConfigureModuleCatalog();
}
}
}
Run Code Online (Sandbox Code Playgroud)
运行后我得到异常:
KeyNotFoundException:未在区域适配器映射中注册 System.Windows.Controls.Grid 类型的 IRegionAdapter。您可以通过覆盖引导程序中的 ConfigureRegionAdapterMappings 方法来为此控件注册 IRegionAdapter。
AutofacBootstrapper好的,但是类没有任何命名ConfigureRegionAdapterMappings为覆盖的方法。
首先我认为有问题AutofacBootstrapper,但即使我将其更改为UnityBootstrapper问题仍然存在。但是第二个允许我覆盖ConfigureRegionAdapterMappings
| 归档时间: |
|
| 查看次数: |
300 次 |
| 最近记录: |