Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

ElementDescriptionVersion IntroducedPro Version Introduced
<Button>A button control associated with a command.1.03.2
<Commands>Predefined list of commands that can be used by buttons anywhere on the ribbon.1.03.2
<Page>A page in the Backstage.1.03.2
<SplitButton>A button control with a drop down that can contain other controls.1.03.2

Attributes

This element supports the following attributes:

AttributeDescriptionVersion IntroducedPro Version Introduced
CaptionThe text to appear on the button.1.03.2
EnabledThe command's default enabled state.1.03.2
KeyThe unique identifier of this command. Must be unique among all other commands. (Required)1.03.2
KeyboardTipThe keyboard tooltip that appears when the user holds the Alt key.1.03.2
LargeIconThe icon used if the button is large.1.03.2
ShortcutThe keyboard shortcut for this command.1.03.2
SmallIconThe icon used if the button is small.1.03.2
TooltipThe text to appear when the user hovers over the button.1.03.2

Caption

The Caption can be any text. When the command is associated to a button, this is the text that will appear on the button. You can omit the caption if you don't want the button to display text, though keep in mind that some buttons do not display a caption depending on where they appear on the ribbon.

...

The Enabled attribute can be set to "true" or "false". This determines the default enabled state of any button associated to this command. You can use the CommandEnabled at runtime to change the enabled states of all associated buttons at once.

...

The Key attribute is arguably the most important as it defines the unique identifier you will use in other parts of the XML to associate the command to a button. See the <Button> element for details on how to associate a command. Note that this key must be unique to other commands' keys, but you can have the same key as a tab or control. Still, it's usually best to keep everything as unique as possible. For example, you can use "SAVE" as a command key and "BTN_SAVE" as a button key for clarity.

...

Note: A command key can only be referenced if the command appears earlier in the XML. For example, let's say you define a command called "PASTE". Any button that appears later in the XML can reference "PASTE", but any button earlier in the XML cannot.

Example

 

Code Block
<Command Key="NEW" Caption="New" Shortcut="Ctrl+N" KeyboardTip="N"
         LargeIcon="Images\32x32\new.png"
         SmallIcon="Images\16x16\new.png"
         Tooltip="Opens a new document." />
 
<Command Key="OPEN" Caption="Open" KeyboardTip="O"
         LargeIcon="Images\32x32\folder_open.png"
         SmallIcon="Images\16x16\folder_open.png"
         Tooltip="Opens a new document." />
 
<Command Key="SAVE" Caption="Save" Shortcut="Ctrl+S" Enabled="False"
         LargeIcon="Images\32x32\save.png"
         SmallIcon="Images\16x16\save.png"
         Tooltip="Saves the document." />
 
<Command Key="SAVE_AS" Caption="Save As" KeyboardTip="A"
         LargeIcon="Images\32x32\save.png"
         SmallIcon="Images\16x16\save.png"
         Tooltip="Saves the document to the selected file." />
 
<Command Key="CLOSE" Caption="Close" KeyboardTip="X"
         Tooltip="Closes the application." />