Prism RegionManager cannot Navigate When RadPane is not Docked

4 posts, 1 answers
  1. Eric
    Eric avatar
    5 posts
    Member since:
    Dec 2010

    Posted 09 May 2014 Link to this post

    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
  2. Answer
    George
    Admin
    George avatar
    1332 posts

    Posted 13 May 2014 Link to this post

    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.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Eric
    Eric avatar
    5 posts
    Member since:
    Dec 2010

    Posted 19 May 2014 in reply to George Link to this post

    Adding that one line of code made everything work.  Thank you for the reply.
  5. Максимейко
    Максимейко avatar
    1 posts
    Member since:
    Oct 2014

    Posted 30 Oct 2014 Link to this post

    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);
    }

Back to Top