The Ribbon class - harborsiem/WindowsRibbon GitHub Wiki

The Ribbon class

The Ribbon class is the main class for the user when using the Windows Forms Designer (WinForms Designer) and when writing the Code-behind for the markup file. Ribbon class is derived from System.Windows. Forms.Control. The Ribbon must be placed directly to a Windows Form by the WinForms Designer with Top docking.

Design time Properties:

Name Description
ResourceName (string) The ResourceName is a reference to an embedded resource file in your project, which contains the compiled RibbonMarkup.xml from the build process with the RibbonTools. Set the Property ResourceName of the Ribbon Control to 'Default namespace of your application assembly'.RibbonMarkup.ribbon. The Ribbon property ResourceName can also be a file-based resource file. In case of a file-based resource file the name must start with file:// like a Uri path. If the RibbonMarkup.ribbon is located in the same path as the application.exe, then you can define ResourceName = file://RibbonMarkup.ribbon If you have a special directory for the path you can also write ResourceName = file://{LocalApplicationData}/your_path/RibbonMarkup.ribbon. Localization is also supported with the file-based resource file. Names of special directories one can find in Environment.SpecialFolder
ResourceIdentifier (string) If you use not the default name parameter for the ribbon compiler uicc.exe, you can set it here. Normally leave this property empty. (since Ribbon Library 2.8.8)
ShortcutTableResourceName (string) In the shortcut file are definitions to the markup commands and their corresponding shortcut keys. Add this file to your project as an embedded resource. The shortcut table is optional. Set the Ribbon Control Property ShortcutTableResourceName to 'Default namespace of your application assembly.name-of-the-shortcut-file' or leave it empty.

Example shortcut file:


<?xml version="1.0" encoding="utf-8" ?>
<RibbonShortcutTable>
  <RibbonShortcutArray>
    <RibbonShortcut CommandId="1008" Shortcut="Ctrl+F"/>
  </RibbonShortcutArray>
</RibbonShortcutTable>

Other public methods, properties and events:

Methods:

Name Description
ConvertToUIImage(Bitmap) Wraps a bitmap object with IUIImage interface.
LoadSettingsFromStream(Stream) The LoadSettingsFromStream method is useful for persisting ribbon state, such as Quick Access Toolbar (QAT) items, across application instances.
SaveSettingsToStream(Stream) The SaveSettingsToStream method is useful for persisting ribbon state, such as Quick Access Toolbar (QAT) items, across application instances.
SetColors(Color, Color, Color), SetBackgroundColor(Color), SetHighlightColor(Color), SetTextColor(Color), GetColors() Methods for color handling to the ribbon. Change ribbon background, highlight and text colors or get the colors.
SetModes(params byte[]) Set current application modes. Values between 0 and 31 allowed. Example: SetModes(0, 3, 5). The current ApplicationModes are now 0, 3 and 5.
ShowContextPopup(uint, int, int) Shows a predefined context popup at a specific location. The first parameter is the Command Id of the popup. The other parameters are the screen position for the popup.
Execute(…), UpdateProperty(…) In former versions of the ribbon library necessary for the user, but don’t use them now. These methods are definitions of the IUICommandHandler Interface, which is implemented in the Ribbon class.

Properties:

Name Description
EventLogger Gives you an instance of the EventLogger class. (since Ribbon Library 2.8.7)
Framework Get ribbon framework object (Interface IUIFramework).
Initialized Check if ribbon framework has been initialized.
Minimized Specifies whether the ribbon is in a collapsed or expanded state.
QuickAccessToolbarDock Specifies whether the quick access toolbar is docked at the top or at the bottom.
ApplicationButtonColor Get or set color of application button. Newer Windows version required (since Ribbon Library 2.14.0)
DarkModeRibbon Get or set Darkmode or Lightmode for the Ribbon. Newer Windows version required (since Ribbon Library 2.14.0)

Events:

Name Description
RibbonEventException User can handle untrapped Exceptions in the other events of the Ribbon controls like Buttons ExecuteEvent.
RibbonHeightChanged This event fires when the Ribbon height changed. (since Ribbon Library 2.9.0)
ViewCreated This event fired when the view is created. You can use it for loading the settings.
ViewDestroy This event fired when the view is in destroy. You can use it for saving the settings.