Skip Navigation LinksHome / Community & Support / Code Library / Silverlight > General and Integration Projects > How to use the RadRibbonBar as Prism Region

Not answered How to use the RadRibbonBar as Prism Region

Feed from this thread
  • Yann avatar

    Posted on Nov 10, 2010 (permalink)

    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.
    Attached files

    Reply

  • Kiril Stanoev Kiril Stanoev avatar

    Posted on Nov 15, 2010 (permalink)

    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

    Reply

  • Djoni Cla Ruffin avatar

    Posted on Feb 2, 2011 (permalink)

    Hi ,
    BIG Thanks for your code.

    Reply

  • Posted on Mar 10, 2011 (permalink)

    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

    Reply

  • terry avatar

    Posted on Mar 18, 2011 (permalink)

    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.

    Attached files

    Reply

  • Petar Mladenov Petar Mladenov admin's avatar

    Posted on Mar 23, 2011 (permalink)

    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

    Reply

  • terry avatar

    Posted on Mar 23, 2011 (permalink)

    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
    Attached files

    Reply

  • Posted on Mar 23, 2011 (permalink)

    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!

    Reply

  • Posted on Mar 28, 2011 (permalink)

    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

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Mar 29, 2011 (permalink)

    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

    Reply

  • peter Intermediate avatar

    Posted on Apr 2, 2011 (permalink)

    Hi,

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

    Thank you very much.

    Peter.

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Apr 7, 2011 (permalink)

    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

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Apr 10, 2011 (permalink)

    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

    Reply

  • terry avatar

    Posted on Apr 10, 2011 (permalink)

    Thanks Tina

    I looked over the RadRibbonBarRegionAdaptersWPF and it answered a number of questions for me.

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Apr 11, 2011 (permalink)

    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

    Reply

  • Rafal avatar

    Posted on Aug 10, 2011 (permalink)

    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

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Aug 10, 2011 (permalink)

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

    Attached files

    Reply

  • Nicolás avatar

    Posted on Sep 15, 2011 (permalink)

    Hi Tina,

    The sample project doesn't work well.

    Greetings!!

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Sep 21, 2011 (permalink)

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

    Reply

  • David Gerding avatar

    Posted on Oct 7, 2011 (permalink)

    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

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Oct 12, 2011 (permalink)

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

    Attached files

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Code Library / Silverlight > General and Integration Projects > How to use the RadRibbonBar as Prism Region