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

...

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." />