How to programmatically disable buttons or add / remove items from DropDown using the Office Ribbon UI interface

I wrote a simple C ++ COM Office add-in that loads the XML definition of a feed and displays a simple feed tab. It has several buttons and dropDown (combobox / droplist). I can handle button press events and combo selection change events like a charm.

Now I want to update the ribbon interface in accordance with the changes in the active document so that some buttons are disabled and some elements are added / removed from combobox.

I searched up and down and couldn't find a way to control this. Am I missing something very obvious? How can I change the enable state of a button from anywhere in my code?

+3
source share
1

, Windows Ribbon: XML . SetModes(), , .

:

  <Application.Views>
    <Ribbon>
      <Ribbon.Tabs>
        <Tab CommandName="cmdTabMain" ApplicationModes="0,1">
          <Group CommandName="cmdGroupCommon" 
                 SizeDefinition="ThreeButtons" 
                 ApplicationModes="0,1">
            <Button CommandName="cmdButtonNew" />
            <Button CommandName="cmdButtonOpen" />
            <Button CommandName="cmdButtonSave" />
          </Group>
          <Group CommandName="cmdGroupSimple" 
                 SizeDefinition="TwoButtons" 
                 ApplicationModes="0">
            <Button CommandName="cmdButtonSwitchToAdvanced" />
            <Button CommandName="cmdButtonDropA" />
          </Group>
          <Group CommandName="cmdGroupAdvanced" 
                 SizeDefinition="FourButtons" 
                 ApplicationModes="1">
            <Button CommandName="cmdButtonSwitchToSimple" />
            <Button CommandName="cmdButtonDropA" />
            <Button CommandName="cmdButtonDropB" />
            <Button CommandName="cmdButtonDropC" />
          </Group>
        </Tab>
      </Ribbon.Tabs>
    </Ribbon>
  </Application.Views>

( # ) _ribbon.SetModes(1) _ribbon.SetModes(0).

enter image description here

+4

All Articles