-
Notifications
You must be signed in to change notification settings - Fork 2
Contextualtabs
Support for Contextual Tabs. The result of this post is a yet another sample, “14-ContextualTabs”, found on the project site.

What are contextual tabs? Contextual tabs are additional tabs that appear when you enable their context. For example, in word, when you select a table in your document, you get two additional tabs (Design and Layout) with commands relevant only to tables.
The basic working unit is a TabGroup, which is a group of contextual tabs with the same context. A TabGroup has a property named ContextAvailable (Property Identifier: UI_PKEY_ContextAvailable) which can have the following values:
-
Active – context is currently available and the tab group should be active (= “selected”)
-
Available – context is currently available (tabs are not necessarily active).
-
NotAvailable – context is currently not available.
More details on this subject can be found at Displaying Contextual Tabs on MSDN.
Using ContextualTabs – Ribbon Markup Following is the views section for defining contextual tabs. The commands section is straightforward.
<Application.Views>
<Ribbon>
<Ribbon.ContextualTabs>
<TabGroup CommandName=‘cmdTabGroupTableTools‘>
<Tab CommandName=‘cmdTabDesign‘>
<Group CommandName=‘cmdGroupDesign‘ SizeDefinition=‘ThreeButtons‘>
<Button CommandName=‘cmdButtonDesign1‘ />
<Button CommandName=‘cmdButtonDesign2‘ />
<Button CommandName=‘cmdButtonDesign3‘ />
</Group>
</Tab>
<Tab CommandName=‘cmdTabLayout‘>
<Group CommandName=‘cmdGroupLayout‘ SizeDefinition=‘TwoButtons‘>
<Button CommandName=‘cmdButtonLayout1‘ />
<Button CommandName=‘cmdButtonLayout2‘ />
</Group>
</Tab>
</TabGroup>
</Ribbon.ContextualTabs>
<Ribbon.Tabs>
<Tab CommandName=‘cmdTabMain‘>
<Group CommandName=‘cmdGroupMain‘ SizeDefinition=‘TwoButtons‘>
<Button CommandName=‘cmdButtonSelect‘ />
<Button CommandName=‘cmdButtonUnselect‘ />
</Group>
</Tab>
</Ribbon.Tabs>
</Ribbon>
</Application.Views>Here we define a single TabGroup for “Table Tools”, with two contextual tabs, “Design” and “Layout”. Each tab has some buttons in it. In addition, we define in the main tab two buttons that we will use to set and unset the “Table Tools” context.
Using ContextualTabs – Code Behind Following is an example of setting the context for a TabGroup thus making it visible.
partial class RibbonItems
{
public void Init()
{
ButtonSelect.Click += new EventHandler<EventArgs>(_buttonSelect_ExecuteEvent);
ButtonUnselect.Click += new EventHandler<EventArgs>(_buttonUnselect_ExecuteEvent);
}
void _buttonSelect_ExecuteEvent(object sender, EventArgs e)
{
if (TabGroupTableTools.ContextAvailable != ContextAvailability.Active)
TabGroupTableTools.ContextAvailable = ContextAvailability.Active;
}
void _buttonUnselect_ExecuteEvent(object sender, EventArgs e)
{
if (TabGroupTableTools.ContextAvailable != ContextAvailability.NotAvailable)
TabGroupTableTools.ContextAvailable = ContextAvailability.NotAvailable;
}
}Here we just register to the ribbon buttons Click events and set the context of the TabGroup accordingly. Of course, in a real application you might use a more sophisticated logic for setting the context.
-
Basics
- Introduction, Background on the windows ribbon framework
- Basic Ribbon Wrapper ; Basic .NET wrappers for windows ribbon framework.
- Quickstart Tutorial
- First WinForms Ribbon Application ; How to create an empty WinForms application with ribbon support.
-
RibbonFramework Controls
- RibbonStrip ; Main class, derived from System.Windows.Forms.Control
- RibbonApplicationMenu
- RibbonButton
- RibbonCheckBox
- RibbonComboBox
- RibbonDropDownButton
- RibbonDropDownColorPicker
- RibbonDropDownGallery
- RibbonFontControl
- RibbonGroup
- RibbonHelpButton
- RibbonInRibbonGallery
- RibbonMenuGroup
- RibbonQuickAccessToolbar
- RibbonRecentItems
- RibbonSpinner
- RibbonSplitButton
- RibbonSplitButtonGallery
- RibbonTab
- RibbonTabGroup
- RibbonToggleButton
-
RibbonFramework EventArgs classes
-
RibbonFramework PropertySet classes
-
RibbonFramework classes, interfaces, enums
-
RibbonFramework features
-
RibbonFramework Samples
- ApplicationMenu with Buttons ; How to use the ribbon application menu.
- ApplicationMenu with SplitButton and DropDownButton ; How to use the ribbon application menu with ribbon split button and ribbon dropdown button controls.
- Tabs, Groups and HelpButton ; How to use ribbon tabs, groups and the ribbon help button control.
- Spinner ; How to use the ribbon spinner control.
- ComboBox ; How to use the ribbon combo box control.
- Changing Ribbon Colors ; How to change the ribbon colors.
- Working with Images ; How to work with images in the ribbon.
- DropDownGallery, SplitButtonGallery and InRibbonGallery ; How to use the ribbon drop down gallery, split button gallery and in ribbon gallery controls.
- CheckBox and ToggleButton ; How to use the ribbon check box and toggle button controls.
- DropDownColorPicker ; How to use the ribbon drop down color picker control.
- FontControl ; How to use the ribbon font control.
- ApplicationModes ; How to work with ribbon application modes.
- ContextualTabs ; How to work with ribbon contextual tabs.
- ContextPopup ; How to work with ribbon context popup.
- RecentItems ; How to work with ribbon recent items control.
- QuickAccessToolbar ; How to work with the ribbon quick access toolbar.
- SizeDefinition ; How to define custom size definitions for ribbon group elements.
- Localization ; How to localize a ribbon.
-
RibbonTools
- RibbonTools64 ; Development support for creating markup files for the Ribbon framework.
- Create a new project ; Create a WordPad sample project
- Specifying Ribbon Commands
- Designing Ribbon Views
- Preview the Ribbon
- Wrapper class RibbonItems ; An auto generated wrapper class from the ribbon markup.
- Convert Image to ARGB Bitmap
-
How to ...