I have a question. I created a region with view and model for a "pdf reader". Then I add this "pdf reader region" to two content controls in two usercontrols. I want to recycle this region with the view and model
The pdf reader is only a view to display a pdf file.
Bootstrapper register:
regionManager.RegisterViewWithRegion(BaseNames.PDF_VIEW_REGION, typeof(
Infrastructure.Base.Views.PdfView));
BaseNames class
public static class BaseNames
{
public const string PDF_VIEW_REGION = "PdfViewBaseRegion";
}
View 1
<ContentControl Grid.Column="1" prism:RegionManager.RegionName="{x:Static contract:BaseNames.PDF_VIEW_REGION }"/>
View 2
<ContentControl Grid.Column="1" prism:RegionManager.RegionName="{x:Static contract:BaseNames.PDF_VIEW_REGION }"/>
Exception:
Prism.Regions.Behaviors.RegionCreationException: "An exception occurred while creating a region with name 'PdfViewBaseRegion'. The exception was: System.ArgumentException: Region with the given name is already registered: PdfViewBaseRegion bei Prism.Regions.RegionManager.RegionCollection.Add(IRegion region) bei Prism.Regions.Behaviors.RegionManagerRegistrationBehavior.TryRegisterRegion() bei Prism.Regions.Behaviors.RegionManagerRegistrationBehavior.StartMonitoringRegionManager() bei Prism.Regions.Behaviors.RegionManagerRegistrationBehavior.OnAttach() bei Prism.Regions.RegionBehavior.Attach() bei Prism.Regions.RegionBehaviorCollection.Add(String key, IRegionBehavior regionBehavior) bei Prism.Regions.RegionAdapterBase
1.AttachDefaultBehaviors(IRegion region, T regionTarget) bei Prism.Regions.RegionAdapterBase1.Initialize(T regionTarget, String regionName) bei Prism.Regions.RegionAdapterBase`1.Prism.Regions.IRegionAdapter.Initialize(Object regionTarget, String regionName) bei Prism.Regions.Behaviors.DelayedRegionCreationBehavior.CreateRegion(DependencyObject targetElement, String regionName). "