Prism 4 and Telerik RadDocking

36 posts, 0 answers
  1. Dave
    Dave avatar
    39 posts
    Member since:
    Jun 2008

    Posted 04 Oct 2010 Link to this post

    I'm following some year-old threads on Prism and the RadDock series, but nothing current.

    Code from Prism 2.2 and RadDock of that same age worked as far as the prototype we had went, but now I want to take it to Prism 4, and the latest tool set. I want to go MEF as well, but would be happy to see a Unity example that works.

    I have this as part of my shell:

            <telerikDocking:RadDocking Grid.Column="2" Grid.Row="1" Grid.RowSpan="2">
                <telerikDocking:RadDocking.DocumentHost>
                    <telerikDocking:RadSplitContainer >
                        <telerikDocking:RadPaneGroup Name="MainRegion" Regions:RegionManager.RegionName="MainRegion">

                        </telerikDocking:RadPaneGroup>
                    </telerikDocking:RadSplitContainer>
                </telerikDocking:RadDocking.DocumentHost>
            </telerikDocking:RadDocking>


    I have a RadSplitContainerRegionAdapter and a RadPaneGroupRegionAdapter.

    I'm not sure I need both, but they were both there.

    My View is a RadPaneGroup which contains a RadPane

    Logic tells me this layout gives me a RadPaneGroup inside a RadPaneGroup, but that's what worked in Prism 2.2 with the old tooling.

    I've tried making the view be the RadPane to avoid the duplication but it doesn't change anything.

    I'm not getting any errors when it runs, just a gray rectangle where the region is.

    FWIW... if I remove all the Telerik, the view gets placed into the region just fine.

    I'm trying to come up with a minimal-order example of this... sounds like a good blog post if I get permission (assuming we get it running).

    Thanks!

    -Dave Campbell
  2. Dave
    Dave avatar
    39 posts
    Member since:
    Jun 2008

    Posted 05 Oct 2010 Link to this post

    I got some off-forum help from a Telerik employee on this.

    As it turns out the RadSplitContainerRegionAdapter that was working in Prism 2.2 had a problem with the 'Reset' case in Prism 4. This was getting called and nuking our content.

    Removed that section, and changed my project to be Silverlight 4 (a *slight* problem I foisted on myself), and things are wonderful again.

    For anyone curious, my shell now has a section like this:

            <telerikDocking:RadDocking Grid.Column="2" Grid.Row="1" Grid.RowSpan="2">
                <telerikDocking:RadDocking.DocumentHost>
                    <telerikDocking:RadSplitContainer Name="MainRegion" Regions:RegionManager.RegionName="MainRegion">
     
                    </telerikDocking:RadSplitContainer>
                </telerikDocking:RadDocking.DocumentHost>
            </telerikDocking:RadDocking>


    My module is of type RadPaneGroup and the primary container is a RadPane.

    Now to convert to MEF :)

    Thanks for looking,

    -Dave



  3. DevCraft banner
  4. George
    Admin
    George avatar
    1332 posts

    Posted 05 Oct 2010 Link to this post

    Hello Dave,

    Thank you for contacting us.

    Miroslav Nedyalkov has a blog post about usage of Prism and RadDocking. It is a very basic example, but it could shed some light on the problem. You could find the blog post here - http://blogs.telerik.com/miroslavnedyalkov/posts/09-08-31/using_the_raddocking_control_with_prism.aspx

    Also, I would suggest you to refer to our forum thread where you can find interesting notes regarding the usage of Prism and RadDocking

    Meanwhile we are working on a new, more advance example of RadDocking with Prism 4. If you are interested, we could inform you when the example and the blog post are ready.

    I really hope this information helps. Please do not hesitate to contact us if you require any further information.


    All the best,
    George
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. George
    Admin
    George avatar
    1332 posts

    Posted 06 Oct 2010 Link to this post

    Hello Dave,

    Here are some updates:

    I modified the attached example in the Miroslav Nedyalkov's blog post. Now, it runs without any problems using the Prism 4 dlls. Attached you can find the updated project.

    I hope this helps. Looking forward to your reply.
     

    Greetings,
    George
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Adrien Pellegrini
    Adrien Pellegrini avatar
    10 posts
    Member since:
    Sep 2009

    Posted 20 Oct 2010 Link to this post

    Hello George,

    How can we use a view that inherits from UserControl class instead of a RadPane/RadDocumentPane.


    Thanks,
    Adrien.
  7. George
    Admin
    George avatar
    1332 posts

    Posted 21 Oct 2010 Link to this post

    Hello Adrien,

    I would suggest you to implement a custom region adapter in order to use views that inherit from UserControl. Miroslav's blogpost shows how to use RadDocking with Prism, but you could always change the project in order to suit your needs. 

    Regards,
    George
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. Adrien Pellegrini
    Adrien Pellegrini avatar
    10 posts
    Member since:
    Sep 2009

    Posted 21 Oct 2010 Link to this post

    I tried to wrap all new item into a RadPane before adding it to the collection of views but it doesn't work.

    When a second item is added to the RadPaneGroup an exception is thrown.

    Value does not fall within the expected range.


    Can you explain me what is it pls?


    Why the e.Action in the RadPanelGroupRegionAdapter go in "Reset" after adding an element. It causes the collection to be cleared ...
    If I comment the code in the "reset" switch, I got the exception shown above.
  9. Adrien Pellegrini
    Adrien Pellegrini avatar
    10 posts
    Member since:
    Sep 2009

    Posted 22 Oct 2010 Link to this post

    Ok, I found the solution for the first error (Value does not fall within the expected range., we cannot named two tab with the same name).

    But I still not understand why the collection event "Reset" is executed after the "add" event.
  10. George
    Admin
    George avatar
    1332 posts

    Posted 26 Oct 2010 Link to this post

    Hello Adrien,

    The current logic is implemented by Microsoft and we don't change anything.

    You could refer to the following link - http://msdn.microsoft.com/en-us/library/system.collections.specialized.notifycollectionchangedaction(VS.95).aspx

    Regards,
    George
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Michael
    Michael avatar
    105 posts
    Member since:
    Nov 2010

    Posted 21 Dec 2010 Link to this post

    OK I like this solution for docking with prism...however..how do we include say a scheduleview or a grid view...because i get the following error when i try to drop one of these controls onto the radpane

    The specified Visual and this Visual do not share a common ancestor, so there is no valid transformation between the two visuals??


  12. George
    Admin
    George avatar
    1332 posts

    Posted 23 Dec 2010 Link to this post

    Hello Dave,

    Could you please give us more detailed information how you drop a ScheduleView /or a GridView/ to a pane? Do you use DragAndDrop? 

    All the best,
    George
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  13. Michael
    Michael avatar
    105 posts
    Member since:
    Nov 2010

    Posted 23 Dec 2010 Link to this post

    OK think I got around it...though I've been changing so many things im not sure if this is a true representation of the solution as it was...

    I didnt have the .content tags in the radpane.
  14. Calabonga
    Calabonga avatar
    29 posts
    Member since:
    Nov 2009

    Posted 07 Feb 2011 Link to this post

    I have a question: How can I use RadPaneGroupRegionAdapter when my prism-application using a MefBootstrapper?
    In xaml:

        <t:RadDocking Grid.Row="1">
            <t:RadDocking.DocumentHost>
                <t:RadSplitContainer>
                    <t:RadPaneGroup prism:RegionManager.RegionName="MainShellRegion" />
                </t:RadSplitContainer>
            </t:RadDocking.DocumentHost>
        </t:RadDocking>

    but region MainShellRegion is not present in collection of regions. I'm using MEF container.

  15. George
    Admin
    George avatar
    1332 posts

    Posted 14 Feb 2011 Link to this post

    Hello,

    We will provide an example about how to use RadDocking control with PRISM 4 + MEF in the near future.
     

    Best wishes,
    George
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  16. Dave Smits
    Dave Smits avatar
    8 posts
    Member since:
    Sep 2009

    Posted 21 Feb 2011 Link to this post

    Hi George,

    Currently i'm looking to that example that you attacht. Now i'm trying to add a new view to the region in the documenthost. I added a button in the shell of your example and in the event handler i wrote :

    private void Button_Click(object sender, RoutedEventArgs e)
    {
    var regionManager = ServiceLocator.Current.GetInstance<IRegionManager>();

    }

    now when i look to the regionManager the region defined in the documenthost is dissapeard? Can you give me a clue to solve it?
  17. George
    Admin
    George avatar
    1332 posts

    Posted 24 Feb 2011 Link to this post

    Hello Dave,

     
    We are aware of this problem with RadDocumentHost. The issue here is tightly related with the Prism framework and usage the RadPaneGroup in the DocumentHost as Region. If you remove the DocumentHost, everything works as expected. I would suggest you to use the SetRegionManager method to register the pane group as region. 


    All the best,
    George
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  18. Mark Jordan
    Mark Jordan avatar
    1 posts
    Member since:
    Feb 2010

    Posted 18 Mar 2011 Link to this post

    Hey there George.

       This has been an interesting thread and I have two comments.

       1. I also had some issues with the RadDocumentHost. I can see what the problems is. It occurs because as PRISM moves up the visual tree to find the attached RegionManager it fails on the DocumentHost element because the .Parent parameter is returning null. I did not bother trying to go any further into the code to try to solve this... Instead (and I think that this is a good stop gap solution) all that is needed is to have a reference to the RegionManager at the appropriate place.
          Personally, I happen to have a Shell structure like this.

    <telerikDocking:RadDocking x:Name="RadDockinging"
         <telerikDocking:RadDocking.DocumentHost
           <telerikDocking:RadSplitContainer x:Name ="RadSplitContainerChart"
               <telerikDocking:RadPaneGroup x:Name="RadPaneGroupChart"
                   Regions:RegionManager.RegionName="DocumentHostRegion">

     

          And I have this little bit of magical code in my constructor that looks like this...

     

    public MainPage(IRegionManager  regionManager) 
    {
        InitializeComponent();
        RadPaneGroupChart.SetValue( RegionManager.RegionManagerProperty, regionManager); 
    }

          Which, I hope you can see, sets the RegionManager into the attached property of the RadPaneGroup. This works because as PRISM travels up the tree it finds a reference to the RegionManager, thus allowing everything to work.

          NOTE: If you are doing any magic work with Scoping of regions things become a lot more messy. But for the average user, this should get them up and running and you are on your own for figuring out which RegionManager you want to reference.

       2. I have been using the RadPaneGroupRegionAdapter that y'all have been nice enough to supply to the general public. It works just fine for me and I am going to continue to use it for a while longer. I have found out why the Reset is occurring (it has to do with making sure that the sort occurs when elements are added or removed), but that is not my comment at the moment.
          I do not think that the methodology being used is valid. The proper way to accomplish this work should be to have a very simple Adapt method that attaches a new RegionBehaviour to the region. Then all of the work should be accomplished in that class. Much like the TabControlRegionSyncBehaviour and the SelectorItemsSourceSyncBehaviour. I plan to spend some time looking at this in the next few weeks. If I get a solution I'll pass it along, and if that is how your developers are looking at things I'd like to know what they are doing.

    Mark,


  19. George
    Admin
    George avatar
    1332 posts

    Posted 24 Mar 2011 Link to this post

    Hello Mark,

     
    We appreciate your opinion and we will be glad if you can share with us your code. If you can post a CodeLibrary project it would be great, too.

    I am glad to assist you further. 

    Regards,
    George
    the Telerik team
  20. Dave Smits
    Dave Smits avatar
    8 posts
    Member since:
    Sep 2009

    Posted 13 Sep 2011 Link to this post

    Hi,

    I did a lot of work to let the docking control work with prism. I made a little example project and you can download it here: https://skydrive.live.com/redir.aspx?cid=d1ba3c73be854a97&resid=D1BA3C73BE854A97!472 (the file you need : Prism.TelerikDocking)

    What does it contain:
    - behavior to get the region manager in the documenthost
    - custom regionadapter to have full control over the docking elements
    - IPageTitle to set the pagetitle in the viewmodel
    - IFocusAware to know with RadPane is the one with focus.
    - ICloseAware to have more control over the closing behavior in the docking

    what is it not:
    - example how to use prism. i don't really use mef and things to init the viewmodels and other feautures of prism are not used. it is just a little example how to use the custom region adapter.

    Known issues:
    - i think with floating windows there are a few open things. Need to dive more in this scenario.
  21. Ubuntu
    Ubuntu avatar
    89 posts
    Member since:
    Jul 2012

    Posted 09 Oct 2011 Link to this post

    Hello George,

    Anyway to have it using MEF ...

    Best regards
  22. Ubuntu
    Ubuntu avatar
    89 posts
    Member since:
    Jul 2012

    Posted 13 Oct 2011 Link to this post

    Thanks guys, found it using a few searchs
    Regards
  23. Vijay
    Vijay avatar
    1 posts
    Member since:
    Nov 2011

    Posted 19 Nov 2011 Link to this post

    Thanks for your gr8 job done, please provide implementation of IfocusAware in MainContentViewModel and for LeftView.
  24. Ubuntu
    Ubuntu avatar
    89 posts
    Member since:
    Jul 2012

    Posted 25 Nov 2011 Link to this post

    Hello Dave,

    I found your regionadapter very useful in my case, I decided to continue using it but I found some problems

    I have structured my dock control as follows:
    <telerik:RadDocking HasDocumentHost="False" x:Name="designdock" Grid.Row="1" Background="Black" BorderBrush="Black" >
        <telerik:RadSplitContainer InitialPosition="DockedTop" >
            <telerik:RadPaneGroup prism:RegionManager.RegionName="DailyUnPostedRegion">
                <i:Interaction.Behaviors>
                    <regionbehaviors:ApplyRegionManagerBehavior/>
                </i:Interaction.Behaviors>
            </telerik:RadPaneGroup>
            <telerik:RadPaneGroup prism:RegionManager.RegionName="DailyUnPostedDetailsRegion">
                <i:Interaction.Behaviors>
                    <regionbehaviors:ApplyRegionManagerBehavior/>
                </i:Interaction.Behaviors>
            </telerik:RadPaneGroup>
        </telerik:RadSplitContainer>
        <telerik:RadSplitContainer InitialPosition="DockedBottom">
            <telerik:RadPaneGroup prism:RegionManager.RegionName="DailyPostedRegion">
                <i:Interaction.Behaviors>
                    <regionbehaviors:ApplyRegionManagerBehavior/>
                </i:Interaction.Behaviors>
            </telerik:RadPaneGroup>
            <telerik:RadPaneGroup prism:RegionManager.RegionName="DailyPostedDetailsRegion">
                <i:Interaction.Behaviors>
                    <regionbehaviors:ApplyRegionManagerBehavior/>
                </i:Interaction.Behaviors>
            </telerik:RadPaneGroup>
        </telerik:RadSplitContainer>
    </telerik:RadDocking>

    in the second SplitContainer (at Bottom) when I open any pane and try to close it I got an error in :
    d.Close += (p, pp) =>
        {
            foreach (PrismRadPane pane in pp.Panes)
            {
                if (pane.OrginalRegion.Views.Contains(pane.Content))
                {
                    pane.OrginalRegion.Remove(pane.Content);
                }
            }
        };

    at the bold line saying : The region does not contain the specified view.
    What could cause such behavior ...

    Appreciate if you could give any resolution to this ....



  25. Dave Smits
    Dave Smits avatar
    8 posts
    Member since:
    Sep 2009

    Posted 25 Nov 2011 Link to this post

    i got a fix for you. need to strip it out of a project so will put it online tomorrow
  26. Ubuntu
    Ubuntu avatar
    89 posts
    Member since:
    Jul 2012

    Posted 26 Nov 2011 Link to this post

    Thanks Dave,

    Excellent, Will be great to have ...


  27. Ubuntu
    Ubuntu avatar
    89 posts
    Member since:
    Jul 2012

    Posted 26 Nov 2011 Link to this post

    Hello Dave,

    I just need to add another thing; How should I communicate with the created RadPanes, I need for example to be able to trap the close/closepreview to check for any changes in order to submit data to the server.

    Another thing is that the PRISM navigation is not working as before, is this normal when using the RegionAdapter?

    Appreciate your feedback.
  28. Dave Smits
    Dave Smits avatar
    8 posts
    Member since:
    Sep 2009

    Posted 27 Nov 2011 Link to this post

    i updated the source code. there is also an example how to use the icloseaware to ask for confirmation before closing a view. even with async things you can use that.
  29. Ubuntu
    Ubuntu avatar
    89 posts
    Member since:
    Jul 2012

    Posted 27 Nov 2011 Link to this post

    Hello Dave,

    Thanks for the update I will give it a try ...
    For the error I reported here it was because my view implement the IRegionLifeTime, that keeps it always true.

    also, I have found a way to (not optimal) to communicate with the radpane and check its viewmodel as follows:
    private void coindock_PreviewClose(object sender, Telerik.Windows.Controls.Docking.StateChangeEventArgs e)
            {
                var dock = ((RadDocking) e.OriginalSource);
                var pane = dock.ActivePane as PrismRadPane;
                var openviews = pane.OrginalRegion.Views;
                foreach (var view in openviews)
                {
                    if (view.GetType() == typeof (CurrencyDetailsView))
                    {
                        CurrencyDetailsView v = view as CurrencyDetailsView;
                        if ( ((CurrencyDetailsViewModel)v.DataContext).StateChanged)
                        {
                            e.Handled = true;
                        }
                    }
                }
            }
    or even simpler and use the PaneStateChange event.
    I will later need to convert it to MVVM.
  30. Ubuntu
    Ubuntu avatar
    89 posts
    Member since:
    Jul 2012

    Posted 27 Nov 2011 Link to this post

    Hello Dave,

    Great Work !!

    Only for the part were you remove the view from the regionManager
    var regionManager = ServiceLocator.Current.GetInstance<IRegionManager>();
    foreach (var region in regionManager.Regions)
    {
        if (region.Views.Contains(this))
            region.Remove(this);
    }
    You have this code at the view and thats why it works fine !!

    If I move this code to the ViewModel, nothing happens because the ViewModel isn't aware of the View itself (MVVM concept).
    I guess I need to search on this at PRISM, How can I trigger the PRISM to remove the related view.
  31. Dave Smits
    Dave Smits avatar
    8 posts
    Member since:
    Sep 2009

    Posted 27 Nov 2011 Link to this post

    this is a problem which also having when adding views to the region manager from the viewmodel. how did you solve that? as i wrote down with the example its not a way how touse prism, mef and MVVM. The example scope is only to show how the adapter can work

    when you can control it all in the viewmodel you can simple implement ICloseAware at yout viewmodel like IFocusAware and IActiveAware

    What i did to get a MVVM pattern is making an abstraction over the region manager thats doing the registration of viewmodels and views. I called it: IViewModelRegionManager

    this has a add method like IViewModelRegionManager.AddViewModel(string regionName, object viewModel);

    this addviewmodel is gonna look with a viewlocator for an fitting view

    the viewmodelregion manager has also a RemoveViewModel(object viewModel) that makes it search in its registrations to the view and then deletes it. In the viewmodel you can use vmRegionManager.RemoveViewModel(this);

    i can put that one online too if your interessed but it also depends if you use ViewFirst or ViewModel first approach. I personally love the vm first and use views only as template
Back to Top
DevCraft banner