There is no way to use both Ribbon Designer and Ribbon XML unless you use (2) separate add-ins. The IAddInExtension.CreateRibbonExtensibilityObject
is only called once for the life cycle of your add-in. You can either choose to implement the interface using the Designer or the XML route. They are two separate API hooks.
The Ribbon Designer is more of a crutch for those new to Office Ribbon development. Once you get familiar with the Ribbon XML approach - it is much simpler and you have much more control over the behaviors (as you indicate in your OP). You can migrate from Ribbon Designer to XML using the Context Menu from the Ribbon Designer surface - although there is some rework for imagery and callbacks because the model is entirely different. It is worth your time to invest in Ribbon XML as it is the only way to extend Context Menus (CommandBars
are deprecated) and Backstage View as there is no designer.
protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
{
return new ContactButtonOverrides();
}
Then within the ContactButtonOverrides
...you can trigger which XML to load via IRibbonExtensibility.GetCustomUI
which passes in the Ribbon ID Type...
public string GetCustomUI(string ribbonID)
{
switch (ribbonID)
{
case "Microsoft.Outlook.Appointment" :
return GetResourceText("OutlookRibbonApp.IPM.Appointment.Ribbon.xml");
case "Microsoft.Outlook.Mail.Compose" :
return GetResourceText("OutlookRibbonApp.IPM.Note.Ribbon.xml");
default:
return "";
}
}
protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
{
if (myCondition == true)
{
return Globals.Factory.GetRibbonFactory().CreateRibbonManager(
new Microsoft.Office.Tools.Ribbon.IRibbonExtension[] { new Ribbon1() });
}
else
{
return Globals.Factory.GetRibbonFactory().CreateRibbonManager(
new Microsoft.Office.Tools.Ribbon.IRibbonExtension[] { new Ribbon2() });
}
}