我想在我的 ui 中使用温莎城堡作为 mvvm 的 IoC 和棱镜。
所以我用 Windsor 引导程序注册了我所有的课程:
Container.Register(
Classes.FromThisAssembly()
.Pick()
.WithServiceAllInterfaces()
.WithServiceSelf()
.WithServiceBase()
.LifestyleTransient());
然后我想导航到我的视图:
RegionManager.RequestNavigate(RegionNames.SideBarRegion, "PreEventNavigationView");
然后抛出异常。来自堆栈跟踪的重要信息是:
{"Activation error occurred while trying to get instance of type Object, key \"PreEventNavigationView\""}
和
{"Requested component named 'PreEventNavigationView' was not found in the container. Did you forget to register it?\r\nThere are 55 other components supporting requested service 'System.Object'. Were you looking for any of them?"}
我认为我需要注册我的组件,system.object
但这也无济于事。有了这个我的用户界面不起作用,我得到了一些奇怪的行为:
Container.Register(
Component.For<PreEventNavigationView,System.Object>()
.ImplementedBy<PreEventNavigationView>().LifestyleSingleton());
我想我在某处读到我不应该在温莎城堡注册对象。如何在温莎城堡中正确使用 Prism Navigation,还是不可能?