Autofac + Prism + RequestNavigate显示错误

时间:2016-07-15 11:41:21

标签: wpf prism autofac

我正尝试使用Autofac + Prism

进行示例应用
class AppBootstrapper : Prism.Autofac.AutofacBootstrapper
{
    protected override void ConfigureContainerBuilder(ContainerBuilder builder)
    {
        base.ConfigureContainerBuilder(builder);

        builder.RegisterType<FirstView>();
    } 
}

稍后我导航到视图

   regionManager.RequestNavigate("MyRegion", new Uri("FirstView", UriKind.Relative), (r) =>
   {
        Debug.WriteLine(r);
   });

但我收到的错误是FirstView未注册。

我知道,使用 Unity ,修复方法是:

container.RegisterType(typeof(Object), typeof(T), typeof(T).FullName);

Autofac的解决方案是什么?

1 个答案:

答案 0 :(得分:1)

builder.RegisterTypeForNavigation<FirstView>();

另见Prism RequestNavigate to new view