Outlook Ribbon XML - Only one instance for all inspectors

303 Views Asked by At

I'm working on an Outlook Add-in which extends the Ribbon for the E-Mail compose inspector and the Backstage. The problem is explained pretty quick. There seems to be only one instance of the ribbon for all inspectors.

When the first inspector window opens, the callback defined in OnLoad fires. For all following inspectors it doesn't. Caused by that fact I can't have an instance of the ribbon "code behind" class for every inspector and all inspectors share the same properties for buttons like visibility, enabled / disabled etc.

How is it possible to have an independent object of a Ribbon for every inspector window?

This is my Ribbon XML:

<customUI onLoad="Ribbon_Load" xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <ribbon>
    <tabs>
        <tab idMso="TabNewMailMessage">
            <group id="groupSpatium">
                <toggleButton id="toggleShare" imageMso="FilePublishAsWebPage" onAction="ToggleShare_Click" description="Click to share files" label="Send" size="large" getEnabled="IsShareEnabled" getPressed="IsShareChecked" />
                <toggleButton id="toggleReceive" imageMso="EmailFormCollectionFolder" onAction="ToggleReceive_Click" description="Click to receive files" label="Receive" size="large" getEnabled="IsReceiveEnabled" getPressed="IsReceiveChecked"  />
            </group>
        </tab>
    </tabs>
  </ribbon>
  <backstage>
    <tab id="ShareBackstage" label="Noerr Share">
      <firstColumn>
        <group id="AlwaysPasswordProtectGroup" label="Password protection and access control" helperText ="Set options for password protection of and access to uploaded files.">
          <bottomItems>
            <checkBox id="AlwaysPasswordProtect" label="Password protect all uploads" getPressed="IsAlwaysPasswordprotectChecked" onAction="AlwaysPasswordprotect_Click"/>
            <checkBox id="AlwaysRequireRegistration" label="Require registration for all password protected uploads" getPressed="IsAlwaysRequireRegistrationChecked" onAction="AlwaysRequireRegistration_Click" getEnabled="IsAlwaysPasswordprotectChecked"/>
          </bottomItems>
        </group>
      </firstColumn>
    </tab>
  </backstage>
</customUI>

Thanks for any Help

1

There are 1 best solutions below

0
On

When OnLoad fires, it will give you the RibbonUI object. Use it to call RibbonUI.Invalidate when you want show/hide/enable/disable your controls.

All of the callbacks will give you the context by passing IRibbonControl interface as a parameter. Read IRibbonControl.Context property - it will be either Explorer or Inspector object where control is hosted.