WPF Prism Request Go to Activation Error

Referring to StockTraderRI, I created a popup area in my shell

infBehaviors:RegionPopupBehaviors.CreatePopupRegionWithName="{x:Static inf:RegionNames.SecondaryRegion}" 

In a module, I am trying to load a view into a popup

 _regionManager.RequestNavigate(RegionNames.SecondaryRegion, new Uri("/OrderDetailsView", UriKind.Relative)); 

OrderDetailsView is a view in the OrderDetailsModule. At this point I get the error below

 Activation error occurred while trying to get instance of type Object, key "OrderDetailsView" 

Stack trace looks below

  at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key) in c:\Projects\CommonServiceLocator\main\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs:line 53 at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService](String key) in c:\Projects\CommonServiceLocator\main\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs:line 103 at Prism.Regions.RegionNavigationContentLoader.CreateNewRegionItem(String candidateTargetContract) 

Any ideas what I can do wrong?

+1
source share
1 answer

You must register your objects for navigation. If you are using Prism 6, you should use Container.RegisterTypeForNavigation<OrderDetailsView>();

When using v5 or less, you should use container.RegisterType(typeof(object), typeof(OrderDetailsView), "OrderDetailsView");

EDIT: when using MEF, you must specify the name of the view in the export attribute:

 [Export("OrderDetailsView")] public class OrderDetailsView : UserControl { ... } 
+1
source

Source: https://habr.com/ru/post/903484/


All Articles