使用Prism和Autofact的NavigationService Xamarin无法找到我的导航

时间:2017-07-11 04:53:20

标签: xamarin prism autofac

我在我的App上注册了我的Xamarin表单页面,该页面继承了PrismApplicationförAutofac

_container.RegisterTypeForNavigation<MasterLayoutPage_View, MasterLayoutPageViewModel>("MasterLayoutPage");

然后我像这样导航:

  await NavigationService.NavigateAsync("MasterLayoutPage");

但它总是说没有注册MasterLayoutPage。 但是,当我检查我的Container的注册类型时,它就在那里,完全添加为上面的注册。

我错过了什么吗?它与Unity合作我只是改为Autofac。

enter image description here

enter image description here

enter image description here

我发现这种奇怪并且想知道它是否可能是一个错误,或者如果带有Autofact的NavigationService无法像Unity那样注册该类型?

1 个答案:

答案 0 :(得分:0)

似乎我的问题是我没有在App.xaml.cs上的覆盖方法RegisterTypes中注册页面我在Initialize重写方法上注册了类型。它确实与Unity一起工作,不知道为什么它与autofac的工作方式不同,因为它与我使用的容器相同......也许prismApplication for unity与PrismApplication for Autofac有一些区别,我将看一看这两个的实现