WPF + Prism + AvanlonDock + Float = KeyNotFoundException

Topics: Prism v4 - WPF 4
Oct 15, 2010 at 10:31 PM

Environment: Prism 4 drop 9, WPF, .NET 4.0, AvalonDock  1.3.3571

Summary: Using Prism regions within a floating Avalondock window causes exception when view is switched from another view.


1. I basically have the visual studio templates to create solutions/projects. 

   see here: http://navajocoder.com/downloads/temp/templates.png

2. In the "quick start solution", the template already creates 2 modules and the shell. In one of the views there is a button that switches another region from view1 to view2.

  private void DisplayView( string viewName ) {

      IRegion mainRegion = _regionManager.Regions[ RegionNames.MainRegion ];

      object view = mainRegion.GetView( viewName );


3. In the xaml code I am using AvalonDock:


<dock:ResizingPanel Orientation="Vertical">

   <dock:DockablePane Margin="0">

      <dock:DockableContent x:Name="three" Title="Main region">

          <ContentControl x:Name="MainRegion" prismrgn:RegionManager.RegionName="MainRegion" />





4. When the main region is a floating window, then trying to switch the view from another view via button click causes this exception:

   System.Collections.Generic.KeyNotFoundException was unhandled  

   Message=The region manager does not contain the MainRegion region.  



5. More screenshots:

   a. float window: http://navajocoder.com/downloads/temp/floatdock1.png

   b. switch from a different view causes: http://navajocoder.com/downloads/temp/floatdock2.png


Has anyone run into this? It seems the RegionManager loses track of the region when the window is in float mode.

Oct 19, 2010 at 4:28 PM


I am not aware how the Avalon control works, but it seems to be related with this, since you can switch between view1 and view2, but you can't do that when the content is floating.

I think that you can find interesting the following forum threads:

On the other hand, a possible issue has been reported for a user when a user control makes use of Adorners, you could read more about this here.

If you consider this an issue in the Prism Library, you could create a work-item for this. This way the product team will be notified.

Fernando Antivero

Oct 26, 2010 at 9:43 PM

Thanks for the response! I will look into it.

Oct 11, 2012 at 7:59 PM


Check the implemantion of PRISM  that uses MEF + Avalon Dock + elysium + WPF ... http://central.codeplex.com/