WPF Prism error when displaying window includes region

I am working on my application WPF

Prism

and trying to show some of my different Views

in Region

. So I am using the following code in mineShell.xaml

and it works well (it shows multiple views under each other).

<ItemsControl x:Name="MainRegion" prism:RegionManager.RegionName="WorkspaceRegion" Width="400"/>

      

I have another one Window

named WinExtra.xaml

. My application instantiates it in Run-Time

when the user clicks on Button

in Shell.xaml

.

Inside WinExtra

I have TabControl

and inside the theme I save UserControls

.

Now I want to put the same ones Region

above inside one of these UserControls

. so I'll write the above code again, but this time insideWinExtra.xaml> TabControl1> TabItem1> UserControl1.xaml

:

<ItemsControl x:Name="MainRegion" prism:RegionManager.RegionName="WorkspaceRegion" Width="400"/>

      

But after instantiating , I get this error:WinExtra

on Showing

Unhandled Exception of type 'Microsoft.Practices.Prism.Regions.Behaviors. RegionCreationException 'occurred in an Unknown module.

Additional information: An exception occurred when creating a region named "WorkspaceRegion". The exception was: System.Collections.Generic.KeyNotFoundException: IRegionAdapter for type System.Windows.Controls.ItemsControl not registered in the scope adapters mapping . You can register an IRegionAdapter for this control by overriding the ConfigureRegionAdapterMappings method in the loader.

at Microsoft.Practices.Prism.Regions.RegionAdapterMappings.GetMapping (ControlType)

at Microsoft.Practices.Prism.Regions.Behaviors.DelayedRegionCreationBehavior.CreateRegion (DependencyObject targetElement, String regionName).

Note: I am using MahApps.Metro

in this project. and all types of windowscontrols:MetroWindow

  • What is the reason for the above error?
  • How can I solve this problem?
+3


source to share


2 answers


For me the problem was that I had a link to the old Prism.Composition package that caused the conflict. Simple Uninstall-Package Prism.Composition <Project> -Force

fixed the problem.



0


source


I found the cause of the error and resolved it.

I was loading the Prism dll assembly while loading my module assembly after displaying the shell.



Now I prevent this prism dll from loading and have no RegionCreationException

in my project

0


source







All Articles