Let's suppose we want to decouple our application that uses RadRibbonBar as a main menu. Doing this using Composite Application Guidelines (Prism) is common scenario, so let's see how to achieve it.

We'll make our RadRibbonBar to serve as RegionManager (This is possible because RadRibbonBar inherits from ItemsControl) and the RadRibbonTabs as actual views that will be plugged-in.

So first we start with declaring RadRibbonBar as RegionManager :

<telerikRibbonBar:RadRibbonBar Regions:RegionManager.RegionName="RibbonRegion" />

Having Region we can focus on creating the actual views. Let's add new Silverlight class library project and name it SalesRibbonTab. Now we need the view itself, so add new class let's say Ribbon that inherits from RadRibbonTab.


public partial class Ribbon : RadRibbonTab
    public Ribbon()


And associate xaml file with it.


<telerikRibbonBar:RadRibbonTab xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="CustomersRibbonTab.Ribbon"
    <telerikRibbonBar:RadRibbonGroup Header="Cusomers">
        <telerikRibbonBar:RadRibbonButton Content="Add" />
        <telerikRibbonBar:RadRibbonButton Content="Remove" />

Ok. Now we need a class that will serve as the glue between the RegionManager and the actual View. It has to inherit from IModule and lets name it


public class SalesRibbonTabModule : IModule
    private readonly IRegionManager regionManager;
    public SalesRibbonTabModule(IRegionManager regionManager)
        this.regionManager = regionManager;
    public void Initialize()
        regionManager.RegisterViewWithRegion("RibbonRegion", typeof(Ribbon));


Having the SalesRibbonTabModule class, now we need to add instance of it to the ModuleCatalog in the Bootstrapper class.


public class Bootstrapper : UnityBootstrapper
    protected override DependencyObject CreateShell()
        Shell shell = Container.Resolve<Shell>();
        Application.Current.RootVisual = shell;
        return shell;
    protected override IModuleCatalog GetModuleCatalog()
        ModuleCatalog catalog = new ModuleCatalog()       
        return catalog;

Now we are all set and can use all the benefits of Composing the UI.

Download the demo project including the Prism dlls from here.

[Update] The project is updated and improved in new post. Find more.

About the Author

Miroslav Miroslavov

is XAML enthusiast. You can follow him on Twitter at @mmiroslavov.


Related Posts