How to use the RadRibbonBar as Prism Region

23 posts, 0 answers
  1. Yann
    Yann avatar
    9 posts
    Member since:
    Aug 2008

    Posted 10 Nov 2010 Link to this post

    Requirements

    RadControls version

    2010.2.924.1040
    (Trial DLL included)
    .NET version

    .NET 4 / Silverlight 4
    Visual Studio version

    VS 2010 (Any version)
    programming language


    C# / Xaml
    browser support

    all browsers supported by RadControls


    PROJECT DESCRIPTION
    A sample project showing how to use the RadRibbonBar as a PRISM region and the RadRibbonTab as nested region

    CONTEXT
    The goal of this project was describe in this forum thread and was to be able to inject the menu of each module inside a RadRibbonBar using the power of PRISM adapter so all modules never know that the shell use a RadRibbonBar. This allow you to change the shell structure at anytime without to change any module.

    To do that we will create a custom (standard clr object) structure to hold all information we need to build the menu:
         - ModuleDefinition
                It contains the name of the module and a list of group.
                This class will be converted to a RadRibbonBar.

          - GroupDefinition
                It contains the name of the group and a list of actions.
                This class will be converted to a RadRibbonTab
     
          - ActionDefinition
                it contains the name, icon and command of the actions and also a list of sub actions
                This class will be converted to a RadRibbonButton or a RadRibbonSplitButton if at least one sub action is defined
     
    The solution contains 4 project:

        * RadRibbonBarPrism used as PRISM Shell and contains the PRISM adapters.
        * RadRibbonBarPrism.Common contains the class ModuleDefinition, GroupDefinition, ActionDefinition
        * RadRibbonBarPrism.ModuleA define a Module with one group and one action
        * RadRibbonBarPrism.ModuleB define a module with one group and one action that contains 2 sub action and also a group with one action in the nested region of the module A.


    NOTE:
    The code provided in this sample project is not ready to be used in production and you should be reviewed to add some error validation.
  2. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 15 Nov 2010 Link to this post

    Hi Yann,

    Thank you for submitting the project. I've updated your Telerik points accordingly.

    All the best,
    Kiril Stanoev
    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
  3. Djoni Cla Ruffin
    Djoni Cla Ruffin avatar
    7 posts
    Member since:
    Jul 2010

    Posted 02 Feb 2011 Link to this post

    Hi ,
    BIG Thanks for your code.
  4. CyclingFoodmanPA
    CyclingFoodmanPA avatar
    6 posts
    Member since:
    Dec 2010

    Posted 10 Mar 2011 Link to this post

    Awesome example.  I am trying to get my head around Prism, utilizng Rocky Lhotka's Csla, the Telerik Controls and everything else and this is a great example.  Thanks so much.

    CyclingFoodmanPA
  5. terry
    terry avatar
    16 posts
    Member since:
    Nov 2008

    Posted 18 Mar 2011 Link to this post

    I'm trying to convert your example RadRibbonBarPrism from SilverLight to WPF and for some reason the module A or module B never show up in the ribbonbar.

    I have attached an example could you look it over and let me know what I have done wrong.

  6. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 23 Mar 2011 Link to this post

    Hi terry,

    We will investigate this problem and try to determine whether the problem is in the RadRibbonBar. We'll write you back in the next 16-17 hours.

    Greetings,
    Petar Mladenov
    the Telerik team
  7. terry
    terry avatar
    16 posts
    Member since:
    Nov 2008

    Posted 23 Mar 2011 Link to this post

    Petar

    I was able to find a solution to this last night, the problem is that the RadRibbonBar can't or doesn't act as a region for WPF (or I still did something else wrong). 

    I found an article on codeproject http://www.codeproject.com/KB/WPF/ViewSwitchingAppsPrism4.aspx.  I took this example and modified it for Telerik RadRibbon and it now works.

    I still have to add one other feature, as its now each module when its loaded inserts a split button to the "Home" ribbontab. When one of the split buttons is clicked that module will futher load into the client area and display some kind of text.

    Attached is a sample
  8. CyclingFoodmanPA
    CyclingFoodmanPA avatar
    6 posts
    Member since:
    Dec 2010

    Posted 23 Mar 2011 Link to this post

    Hi Petar, Terry

    Funny, I have been working on the same example on CodeProject.com today.  I noticed the Telerik example is hard coding the modules in there and the example on CodeProject utilizes Module Discovery.  I am thinking that there needs to be an .xaml file in the Shell project titled ModuleCatalog.xaml which has the modules in there and when the bootstrapper is loaded, it reads that xaml file to discover the modules.

    This way, you can drop in a module and modify the xaml file and Prism will take care of discovering the module.  The author on CodeProject puts things in a Modules directory, but that works for WPF xbap files and I don't think it works for SL xbap files as I have been working with SL for a while and had to learn some WPF stuff to figure out the example.  I have just started working on a SL example similar to what Terry is doing.  Terry and I must be on the same page!  Anyway, I will be looking forward to see how this blog progresses and I will continue working on stuff.  Unfortunately, we are having a severe thunder storm now and even though I have a UPS, I am going to be shutting down for a while!  Darn, I am on a roll :).

    Keith

    Ok, I think one of the problems Terry is having is that this is the Silverlight forum for the RadRibbonBar and his example is Wpf as was the sample on CodeProject.  I am battling with getting the example working in SL with the RadRibbonBar.  Wpf are similar but are also VERY DIFFERENT in places where I am trying to get things to work.  If I get it working in SL, I will upload for everyone to see and play with.  However, don't hold your breath as I am learning Prism, specifically Unity DI and am trudging through learning Prism, Telerik Controls, etc.  Gotta love this stuff!
  9. CyclingFoodmanPA
    CyclingFoodmanPA avatar
    6 posts
    Member since:
    Dec 2010

    Posted 28 Mar 2011 Link to this post

    Awesome example.  I am trying to figure out how to do something similar to this utilizing Prism 4 and all the code in XAML and utilizing Module Discovery - having all the modules in an xaml file and loading them in the bootstrapper.  I have most of it working except for the subactions on this example.  For example, I have a group called Operations.  Operations has 3 major sub groups - Products, Profit Centers, Sources.  Products has a number of options under it.  I would like 3 buttons under operations - Products, Profit Centers, Sources, then have a drop down list for those items.  For example, Products button would have a drop down of Product Type, Tax Product, have a separator, then Product.  I would like to have all of this in xaml, but utilize either ICommand or a DelegateCommand for the events. 

    Any recomendations?

    Thanks,
    Keith
  10. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 29 Mar 2011 Link to this post

    Hello guys,

    We don't have examples implementing exactly what you are looking for. However, in the next days we will try to put up a few examples of the RadRibbonBar utilizing PRISM and MEF for both WPF and Silverlight.

    We will get back to you as soon as possible.

    Greetings,
    Tina Stancheva
    the Telerik team
  11. HDC
    HDC avatar
    214 posts
    Member since:
    Dec 2010

    Posted 02 Apr 2011 Link to this post

    Hi,

    I'm working on something similar. is it possible to provide a sample using the MefBootstrapper too please?

    Thank you very much.

    Peter.

  12. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 07 Apr 2011 Link to this post

    Hello CyclingFoodmanPA,

    We will do our best to prepare examples for both Silverlight and WPF and attach them here tomorrow the latest.

    All the best,
    Tina Stancheva
    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
  13. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 10 Apr 2011 Link to this post

    Hi guys,

    The project initially attached to this CodeLibrary illustrates how to define custom region adapters for the RadRibbonBar in order to use the control as a region with PRISM. Since the example is for Silverlight and some of you had difficulties converting it to work in WPF, I attached its WPF version (RadRibbonBarRegionAdaptersWPF.zip).

    I also attached a sample illustrating how to use the RadRibbonBar for Silverlight in a PRISM scenario, where the modules are registered in a XAML file (RibbonBarPrismHowTo.zip). Basically this example illustrates how to create two modules defining RibbonTabs inside the RibbonBar and one module that creates a RibbonGroup inside the second RibbonTab. This scenario also requires some dependencies between the modules to be defined, since the first tab should be loaded before the second one and also the third module cannot be loaded unless the second tab is initialized. The dependencies between the modules are also defined in the XAML file.

    I also attached a sample implementing the above described scenario but taking advantage of MEF - RibbonBarMEFHowTo.zip.

    I hope those examples will help you get started on your applications. If you need more info, please let us know.

    All the best,
    Tina Stancheva
    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
  14. terry
    terry avatar
    16 posts
    Member since:
    Nov 2008

    Posted 10 Apr 2011 Link to this post

    Thanks Tina

    I looked over the RadRibbonBarRegionAdaptersWPF and it answered a number of questions for me.
  15. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 11 Apr 2011 Link to this post

    Hello terry,

    I am glad to hear that. Please let us know if we can further assist you.

    Greetings,
    Tina Stancheva
    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
  16. Mariusz
    Mariusz avatar
    24 posts
    Member since:
    Mar 2011

    Posted 10 Aug 2011 Link to this post

    Hello,

    I've made a solution using prism and ribbonbar. The problem is whenever I add first RibbonTab from a module to the RibbonBarRegion it is shown twice. e.g:

    1. add "tab1" tab
    2. add "tab2" tab

    result:
    [tab1][tab2][tab1]

    1. add "tab1" tab
    2. add "tab2" tab
    2. add "tab2" tab

    result:
    [tab1][tab2][tab2][tab1]

    These duplicated tabs act like one tab (if I select one, both will be selected). No matter how many tabs I add (even the same tabs), always that added at first is being duplicated.

    However if at first I create and add a tab in code (e.g.
    _regionManager.RegisterViewWithRegion("RibbonRegion", () => new RadRibbonTab());
    )
    the tab is not duplicated, and all other tabs are also displayed correctly.

    Any Ideas?

    Cheers,
    Rafal
  17. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 10 Aug 2011 Link to this post

    Hello Rafal,

    Due to the many known limitations of the RibbonBar we decided that it would be best to provide a new implementation of the control - RadRibbonView. It basically has the the RadRibbonBar API but it significantly improves its functionality, databinding and design time support. You can find more info about the differences between the two controls here.

    I attached a sample project taking advantage of the new RibbonView control in a PRISM scenario. Please have a look at it and let me know if it helps.

    Greetings,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  18. Nicolás
    Nicolás avatar
    7 posts
    Member since:
    Sep 2011

    Posted 15 Sep 2011 Link to this post

    Hi Tina,

    The sample project doesn't work well.

    Greetings!!
  19. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 21 Sep 2011 Link to this post

    Hi Nicolás,

    Can you please elaborate on the issues you experienced with the solution. It works as expected on our side. However, I slightly modified it as some properties are irrelevant to the illustrated scenario and I removed them (I removed RadRibbonGroup.ItemsSource collection in Module3View as the RibbonGroup is used as a region and its Items collection is getting populated). I also noticed that I have set the RadRibbonButton (from Module2View) size to Small but this means that only its SmallImage will be displayed and as no such property is defined for the control, no content will be visible for the button. This is why I changed the Size to Medium so that the Text binded property can be displayed.

    Now the project properly demonstrates how the RibbonView control can be used in a PRISM scenario. However, if you are experiencing any issues that I am missing, please let me know.

    Kind regards,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  20. David Gerding
    David Gerding avatar
    44 posts
    Member since:
    Sep 2005

    Posted 07 Oct 2011 Link to this post

    Could you please post a comparable example for using RibbonView with WPF and Prism?  Am I correct that I no longer need a RibbonBarAdapter?  I don't see one in your silverlight version... pretty stuck.
    Thanks,
    Dave G
  21. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 12 Oct 2011 Link to this post

    Hi David Gerding,

    I attached a sample project illustrating how to use the RadRibbonView in a PRISM scenario in WPF.

    Basically when a UI control is exposed as a region, a region adapter is used for creating a region and associating it to the control. Since the RadRibbonView is an ItemsControl the default ItemsControlRegionAdapter is used to control its behavior as a region in PRISM. This is why you'll need to configure a custom RegionAdapter only in case you need to further customize the behavior of the RadRibbonView as a region. For example if you add views that are not of type RadRibbonTab you might want to change the way they are added in the RadRibbonView control and manually create the RadRibbonTab containers that will wrap them.

    I hope this information and the sample project will help you. If I can further assist you, please let me know.

    Regards,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  22. Suresh
    Suresh avatar
    2 posts
    Member since:
    Mar 2013

    Posted 20 Mar 2013 Link to this post

    Hi,
    Any updated examples in WPF using ribbon with Prism 4.1.
  23. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1183 posts

    Posted 25 Mar 2013 Link to this post

    Hi Suresh,

    For the moment we not have a solution implementing the new features of PRISM 4.1. However, I tried the solution provided by Tina with PRISM 4.1 and it seems that it is working as expected. Please try to implement the features that you need and let us know if you need any further assistance. We will be happy if we can help you.

    Regards,
    Pavel R. Pavlov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top