Hi,
I'm Using Composite Application Architecture for my application. I want to add Ribbon Tab Item from my loosely couple modules. In modules I can have only User Controls. I want to know how I can add user control for ribbon tab collection as a Ribbon Tab Item.
You ultimately need to create a RibbonTabItem and then you could set its Content as your usercontrol but you are going to have to provide your own glue/logic for creating the tab, initializing it and adding that to the XamRibbon's Tabs collection. This could be done by writing your own Region for xamRibbon if you're using CAL.
Thanx for your reply. I want to know more details about it. What you meant by "Writing your own region"
What I have done is,
I have defined XamRibbon as a region & created custom region adapter for XamRibbon, This adapter handle adding Tabs to ribbon.
My Modules they have Views that inherit from RibbonTabItem & they are registering with XamRibbon's defined region.
with this approach I cant add contextual tabs into XamRibbon. Because whole ribbon is defined as region, custom adapter add all registered tabs into normal tab collection, because he knows only one region.
Perhaps another customer who has tried to use CAL with their own adapter for XamRibbon can chime in here. You might also want to check with the CAL/Prism group in case there is some support in CAL itself to obtain metadata from the view or perhaps define your own custom interface that the view must implement that provides some details about how to host the view.
Hi Andrew,
I have written a CAL RegionAdapter for the RibbonTab.
It's pretty straight forward, except that you must prevent the collection from sending events.
If you don't do so, you get ugly ArgumentOutOfRange exceptions.
I have attached the code.
Sincerely,
Markus
Hi Markus, I've implemented your RegionAdapter for the RIbbonTab, but I'm a little confused on how my XAML should look. Do I register the entire ribbon control tab as the region? Can you provide a sample of your XAML markup?
Thanks in advance,
Donavan
Hi Donavan,
you have to register the RegionAdapter with the CAL infrastructure in the bootstrapper as described by Alex.
protected override RegionAdapterMappings ConfigureRegionAdapterMappings() { var mappings = base.ConfigureRegionAdapterMappings(); mappings.RegisterMapping(typeof(TabGroupPane), Container.Resolve<TabGroupPaneRegionAdapter>()); mappings.RegisterMapping(typeof(XamRibbon), Container.Resolve<XamRibbonRegionAdapter>()); mappings.RegisterMapping(typeof(RibbonTabItem), Container.Resolve<RibbonTabItemRegionAdapter>()); return mappings; }
Than you have to register your region with the region manager. This can be done in XAML
<igRibbon:RibbonTabItem Header="Home" cal:RegionManager.RegionName="{x:Static inf:RegionNames.ShellRibbonHome}">
or you attach the RegionManager.RegionName dependency property in code.
You must derive your view from RibbonTabItem (not UserControl)
public class RibbonTabCaseManagementView : RibbonTabItem, IRibbonTabCaseManagementView { ...}
and than you can add it to the region:
_regionManager.AddToRegion(RegionNames.ShellRibbonHome, _container.Resolve<IRibbonTabCaseManagementPresenter>().View);
If you have the Adapter from Alex + mine you can add tabs to the ribbon, by giving the whole ribbon a region-name and adding items to a tab by giving the tab a region-name.
Hope that helps
Donavan,
I've answered your question in this forum thread.