So if you are using Prism, then you should be using the Prism container. I think Prism 7 had an Autofac version, but they depreciated that. starting at Prism 8. I would suggest Prism.DryIoc as that is the direction they are moving with Prism 9. You want to add one of the Prism packages with a container either Prism.Unity or Prism.DryIoc and then let Prism do the rest
Prism provides a method in App.Xaml.cs to override with registrations.
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry.Register<IComboBoxItem, ComboBoxItem>();
containerRegistry.Register<IToolbarCommand, ToolbarCommand>();
containerRegistry.RegisterSingleton<IConnectionCheck, PortalConnectionCheck>();
containerRegistry.RegisterSingleton<ILog4NetFacade, Log4NetLogger>();
//If you did not have Modules or Regions you could register a view for Navigation here
containerRegistry.RegisterForNavigation<MobileAppMapView, MobileAppMapViewModel>();
}
If you have Modules the initialization is done in the IModule implementation and would be along these lines
/// <summary>
/// Map Module is primary application module responsible for inital loading
/// of the map and all interations with the MapView
/// </summary>
public class MapModule : ModuleBase
// I have a ModuleBase class that implements IModule so that common initialization code is put there
{
public override void RegisterTypes(IContainerRegistry containerRegistry)
{
base.RegisterTypes(containerRegistry);
containerRegistry.Register<IMapLoadService, MapLoadService>();
}
public override void OnInitialized(IContainerProvider containerProvider)
{
base.OnInitialized(containerProvider);
//RegionManager comes from base class this is is how one gets RegionManager in Module
// RegionManager = containerProvider.Resolve<IRegionManager>();
RegionManager.RegisterViewWithRegion(RegionNames.MapRegion, typeof(MobileAppMapView));
}
}
There is no need to be setting a DataContext, Prism does that for you
As an aside: I would avoid naming my View MapView, I find this confuses things sometimes because it is the same name as the esri class
Thanks,
-Joe