This is a migrated thread and some comments may be shown as answers.

Prism RegionManager cannot Navigate When RadPane is not Docked

3 Answers 226 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Veteran
Iron
Eric asked on 09 May 2014, 05:53 PM
I have a MEF Prism region defined in a RadPane.  As long as the pane is docked in the DocumentHost, everything works correctly.  However, if I pull the pane out of the host so that it is floating outside of the main application, Prism navigation does not work when I call RegionManager.RequestNavigate.  I then drag the pane back into the host, and navigation starts working, again.  Is there any known reason why navigation would work in one state but not the other?  Is there a work around?  I am running Telerik 2014 Q1.


<telerik:RadPane Header="Document Viewer" Name="ChartViewerPane"
                    telerik:RadDocking.SerializationTag="MyPane">
    <telerik:RadPane.Content>
        <ContentControl regions:RegionManager.RegionName="{x:Static inf:RegionNames.MyRegionName}"></ContentControl>
    </telerik:RadPane.Content>
</telerik:RadPane>

I tried following the directions in this blog post, but nothing changed once I added the code to my solution.

http://blogs.telerik.com/xamlteam/posts/13-12-11/using-raddocking-with-prism-in-wpf-silverlight

3 Answers, 1 is accepted

Sort by
0
Accepted
George
Telerik team
answered on 13 May 2014, 08:18 AM
Hi Eric,

The nature of this problem comes from the PRISM framework implementation. Let me explain:
  • when request navigate a view into region, the PRISM framework first checks and update its regions.
  • when updating if a region is not found, it will be removed from the region manager and nothing further will be executed
  • how PRISM updates its regions - it tries to find the RegionManager from the region (the ContentControl in the pane). It uses a recursive call through the parent UIElements, starting from the region.
  • When the pane is docked, PRISM finds the RegionManager from the Shell (I assume the Docking control is in the Shell). But, when a pane goes floating, it's placed inside a Window and the above code which recursively searches for parent element which has RegionManager fails.

The issue can be reproduced without Docking control. It's enough to pull out the registered region from the VisualTree and place it inside another opened Window.

In this scenario, I would suggest making sure that the parent UIElement of ContentControl has set RegionManager.

Please, refer to the attached project. It uses the MS example with PRISM - ViewSwitchingNavigation from the PRISM package, but the MainContentRegion is placed inside a pane. Note that the following code is required in order to request navigate a view when the pane is floating:

public void OnImportsSatisfied()
 {
     Microsoft.Practices.Prism.Regions.RegionManager.SetRegionManager(this.pane, this.RegionManager);
            ....
}

I hope this helps.

Regards,
George
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Eric
Top achievements
Rank 1
Veteran
Iron
answered on 20 May 2014, 02:02 AM
Adding that one line of code made everything work.  Thank you for the reply.
0
Максимейко
Top achievements
Rank 1
answered on 30 Oct 2014, 04:10 PM
Or you can simply subscribe to the OnPaneStateChange event of RadDocking control and set the RegionManager in its handler

private void RadDocking_OnPaneStateChange(object sender, RadRoutedEventArgs e)
{
      RadPane radPane = e.OriginalSource as RadPane;
      if (radPane != null) 
         RegionManager.SetRegionManager(radPane, NavigationModule.RegionManager);
}

Tags
Docking
Asked by
Eric
Top achievements
Rank 1
Veteran
Iron
Answers by
George
Telerik team
Eric
Top achievements
Rank 1
Veteran
Iron
Максимейко
Top achievements
Rank 1
Share this question
or