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?
source to share