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)
Avatar

Hi,

 

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:

 

<UserControl>

...

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


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

<!--Docking Manager and Panels-->
<docking:DockSite Grid.Row="2"
x:Name="dockSite"
Loaded="DockSite_Loaded"
>
<docking:SplitContainer>
<!--______________________ Graphical View panel ______________________________________________-->
<docking:ToolWindowContainer>
<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:ToolWindow>
</docking:ToolWindowContainer>

<docking:SplitContainer Orientation="Vertical">

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

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

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

</docking:SplitContainer>

</docking:SplitContainer>

<!--______________________ Options View panel ______________________________________________-->
<docking:DockSite.AutoHideRightContainers>

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

</docking:DockSite.AutoHideRightContainers>
</docking:DockSite>


</UserControl>

 

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?

 

Thanks.

Comments (3)

Posted 7 years ago by eric
Avatar

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

https://msdn.microsoft.com/en-us/library/ff921162.aspx

 

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
Avatar

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
Avatar

Hi,

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:

http://www.actiprosoftware.com/community/thread/23649/binding-error-on-second-load-of-a-window-ob

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.

 

Thanks!

The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.