DockSite inside PRISM Scoped Region

Docking/MDI for WPF Forum

Posted 7 years ago by eric
Version: 16.1.0635
Platform: .NET 4.5
Environment: Windows 10 (64-bit)



im facing an issue after upgrading actipro from .622 to .634.

My application is using prism and is calling another window that is using the actipro docking MDI.

Since this window can be called multiple times, we are using PRISM scoped regions with code similar to:

' Access the region.
defaultLayoutRegion = regionManager.Regions(RegionNames.ZEDefaultLayoutRegion)
' Get a Default Layout object.
m_defaultView = container.Resolve(Of DefaultLayout)()

' Create a scoped (local) region manager.
m_localRegionManager = defaultLayoutRegion.Add(m_defaultView, Nothing, True)

The default view looks like this:




<ContentControl prism:RegionManager.RegionName="{x:Static local:RegionNames.RibbonRegion}"
prism:RegionManager.RegionContext="{Binding GraphicalAreaContext}"

<ContentControl Grid.Row="1"
prism:RegionManager.RegionName="{x:Static local:RegionNames.ZEQuantitySelectionRegion}"/>

<!--Docking Manager and Panels-->
<docking:DockSite Grid.Row="2"
<!--______________________ Graphical View panel ______________________________________________-->
<docking:ToolWindow Name="GraphicalArea">
<!--Title is provided by the ResyncPanelsTitle in the DockingSiteTools-->
<ContentControl Margin="2"
prism:RegionManager.RegionName="{x:Static local:RegionNames.GraphicalAreaRegion}"
prism:RegionManager.RegionContext="{Binding GraphicalAreaContext}"/>

<docking:SplitContainer Orientation="Vertical">

<!--______________________ List of Zones View panel ______________________________________________-->
<docking:ToolWindow Name="ZonesList">
<!--Title is provided by the ResyncPanelsTitle in the DockingSiteTools-->
<ContentControl prism:RegionManager.RegionName="{x:Static local:RegionNames.ZonesListRegion}" />

<!--______________________ Properties View panel ______________________________________________-->
<docking:ToolWindow Name="Properties">
<!--Title is provided by the ResyncPanelsTitle in the DockingSiteTools-->
<ContentControl Name="ZoneEditorDisplay"
prism:RegionManager.RegionName="{x:Static local:RegionNames.PropertyRegion}" />
<!--______________________ Transformations View panel ______________________________________________-->
<docking:ToolWindow Name="Transformations">
--><!--Title is provided by the ResyncPanelsTitle in the DockingSiteTools--><!--
<ContentControl prism:RegionManager.RegionName="{x:Static local:RegionNames.TransformationsRegion}" />

<!--______________________ Vertices Editing View panel ______________________________________________-->
<docking:ToolWindow Name="Vertices">
<!--Title is provided by the ResyncPanelsTitle in the DockingSiteTools-->
<ContentControl prism:RegionManager.RegionName="{x:Static local:RegionNames.VerticesRegion}" />



<!--______________________ Options View panel ______________________________________________-->

<docking:ToolWindowContainer >
<docking:ToolWindow Name="DisplayOptionsPnl"
<!--Title is provided by the ResyncPanelsTitle in the DockingSiteTools-->
<ContentControl Name="DisplayOptionsRegion"
prism:RegionManager.RegionName="{x:Static local:RegionNames.DisplayOptionsRegion}" />




BEFORE, in V.622 all my regions defined in the docking site would get added to the m_localRegionManager that was created.

But as soon as i upgrade to  .634 the same exact code doesn't work.  The only regions i see in my m_localRegionManager are the one i defined outside the DockSite (the 2 content control).

Is that a known bug? Are we using it incorrectly?



Comments (3)

Posted 7 years ago by eric

To add, we the following microsoft post regarding the creation of a view in a scoped region:


Also we are still using PRISM 4 as we had no time to move to PRISM 6 (planned after our release)

[Modified 7 years ago]

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA

Hi Eric,

In the 2016.1 version rewrite of Docking/MDI, we implemented the control using more standardized template and composition techniques.  A drawback of that is that some of the deeper control hierarchies aren't constructed by WPF until all the templates have been applied, which should be done by the time the DockSite is Loaded. 

I think what you might be running into here is that Prism is searching for controls before that happens.  In our Shell.OnLoaded method, we have this information:

private void OnLoaded(object sender, RoutedEventArgs e) {
	if (regionManager != null) {
		// NOTE: If you need to access regions within docking windows explicitly defined in XAML (this sample doesn't have any), 
		//   then you must manually set the region manager like this once the dock site has loaded,
		//   where 'myToolWindow' references a ToolWindow with x:Name="myToolWindow" that would have been in XAML

		// RegionManager.SetRegionManager(myToolWindow, regionManager);
		// RegionManager.UpdateRegions();

Please give that a try.

Actipro Software Support

Posted 7 years ago by eric


thanks for the quick reply.

Indeed this fixes my issue.


I would like to add two things:

1- in my case, i am in a scoped regions, therefore i needed to inject to my view the correct scoped region otherwise PRISM passes the GlobalRegionManager.

2- This is what caused my other issue:

The reason was that my view disposal method, which relied on finding the view in the region manager, would never dispose on certain view which let my old view in memory in a inconsistent state.



The latest build of this product (v24.1.2) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.