棱镜 5 导航与温莎城堡

Prism 5 Navigation with windsor Castle

我想在我的 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 注册我的组件,但这也无济于事。有了这个,我的 UI 不起作用,我得到了一些奇怪的行为:

        Container.Register(
            Component.For<PreEventNavigationView,System.Object>()
                .ImplementedBy<PreEventNavigationView>().LifestyleSingleton());

我想我在某处读到我不应该在温莎城堡注册对象。 如何在温莎城堡中正确使用 Prism Navigation 或无法使用?

这部分有问题:

        Container.Register(
        Classes.FromThisAssembly()
            .Pick()
            .WithServiceAllInterfaces()
            .WithServiceSelf()
            .WithServiceBase()
            .LifestyleTransient());

我只使用完整命名空间(或者 windsor 默认使用)注册了它们,而不仅仅是 class 名称。 所以有2个灵魂:

RegionManager.RequestNavigate(RegionNames.SideBarRegion, "Full.NameSpace.PreEventNavigationView");

        Container.Register(
        Classes.FromThisAssembly()
            .Pick()
            .Configure(registration => registration.Named(registration.Implementation.Name))
            .WithServiceAllInterfaces()
            .WithServiceSelf()
            .WithServiceBase()
            .LifestyleTransient());