2015-07-13 82 views
3

我的工作我的WPFPrism的應用程序,並試圖表現出我的一些不同ViewsRegion。所以我在我的Shell.xaml中使用下面的代碼,它運行良好(它顯示了彼此之下的多個視圖)。WPF棱鏡誤差包括地區

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

我有另一個Window命名WinExtra.xaml。當用戶點擊Shell.xaml中的Button時,我的應用程序在Run-Time上創建它的一個實例。

WinExtra裏面我有一些TabControl和內部主題我保留我的UserControls

現在我想把像上面一樣的Region放在這些UserControls之一內。所以我寫再次上面的代碼,但這次WinExtra.xaml> TabControl1> TabItem1> UserControl1.xaml:在我創建的WinExtraon Showing它的一個實例

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

,我得到這個錯誤:

An unhandled exception of type 'Microsoft.Practices.Prism.Regions.Behaviors.RegionCreationException' occurred in Unknown Module.

Additional information: An exception occurred while creating a region with name 'WorkspaceRegion'. The exception was: System.Collections.Generic.KeyNotFoundException: The IRegionAdapter for the type System.Windows.Controls.ItemsControl is not registered in the region adapter mappings. You can register an IRegionAdapter for this control by overriding the ConfigureRegionAdapterMappings method in the bootstrapper.

at Microsoft.Practices.Prism.Regions.RegionAdapterMappings.GetMapping(Type controlType)

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

注:我在這個項目中使用MahApps.Metro。並且所有窗口類型均爲controls:MetroWindow

  • 上述錯誤的原因是什麼?
  • 我該如何解決它?
+0

我創辦了錯誤原因及解決它。在顯示shell之後加載我的模塊組件時,我也加載了Prism dll程序集。現在我防止這個棱鏡DLL加載,並沒有任何'RegionCreationException'在我的項目 – RAM

回答

0

對我來說,問題是我有一個引用衝突的舊的Prism.Composition包的引用。一個簡單的Uninstall-Package Prism.Composition <Project> -Force修復了這個問題。

0

我創建了錯誤原因&解決了它。

我在顯示shell之後加載我的模塊程序集期間加載了Prism dll程序集。

現在我防止這種棱鏡的dll加載和沒有任何RegionCreationException在我的項目