Skip to main content
A newer version of this page is available. .

RibbonPageCategory Class

Represents a Ribbon page category.

Namespace: DevExpress.XtraBars.Ribbon

Assembly: DevExpress.XtraBars.v19.2.dll

Declaration

public class RibbonPageCategory :
    BaseRibbonComponent,
    ISupportMergeOrder,
    ICloneable,
    IXtraObjectWithBounds

Remarks

Ribbon pages in the Ribbon Control belong to either the default or custom categories. Pages that belong to the default category are considered to be the main pages of a Ribbon application, while pages that belong to custom categories are designed to provide context dependent commands. These pages should not be visible all the time, but displayed only when necessary.

The RibbonPageCategory represents a Ribbon page category. Its RibbonPageCategory.Pages property specifies a collection of pages associated with this category. Adding a page to this collection automatically associates it with this category. To get a Ribbon page’s category, use the RibbonPage.Category property.

The Ribbon Control always contains the default page category, which can be accessed via the RibbonControl.DefaultPageCategory property. The category’s RibbonPageCategory.Pages collection allows you to add and manipulate “main” tab pages in the RibbonControl. It’s also possible to access the default category’s pages via the RibbonControl.Pages collection.

The RibbonControl.PageCategories property specifies a collection of custom categories. These allow contextual tab pages to be implemented, as in the Microsoft Office 2007 UI. To create a contextual tab page, first create a custom category (a RibbonPageCategory object), add it to the RibbonControl.PageCategories collection. Then add a Ribbon page that will represent the contextual tab page to the category’s RibbonPageCategory.Pages collection.

See the Categories and Contextual Tabs topic to learn more.

Example

The following example demonstrates how to create contextual tab pages in the RibbonControl in code.

In the example, a RibbonControl control is created containing one permanently displayed page (“Home”) and two contextual pages (“Format” and “Clipboard”). The contextual pages are combined into a custom page category (“Selection”).

Contextual pages are hidden when they are created. They are made visible later via the category’s RibbonPageCategory.Visible property.

The following image demonstrates code execution:

CreateContextualTabs_Ex

using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraBars;

// Create a RibbonControl.
RibbonControl Ribbon = new RibbonControl();
// Assign a collection of images that will be used by bar items.
Ribbon.Images = imageCollection1;            
// Create a page and associate it with the default category.
RibbonPage pageHome = new RibbonPage("Home");
Ribbon.Pages.Add(pageHome);
// Create a custom Selection page category.
RibbonPageCategory catSelection = new RibbonPageCategory("Selection", Color.LightPink, false);
Ribbon.PageCategories.Add(catSelection);
// Create two contextual pages (Format an Clipboard)in the Selection category.
RibbonPage contextPageFormat = new RibbonPage("Format");
RibbonPage contextPageClipboard = new RibbonPage("Clipboard");
catSelection.Pages.AddRange(new RibbonPage[] {contextPageFormat, contextPageClipboard});

// Customize the Format page by adding a Format group with two bar items to it.
RibbonPageGroup groupFormat = new RibbonPageGroup("Format");
groupFormat.AllowTextClipping = false;
// Add two items to the Format group
BarButtonItem itemCopy = new BarButtonItem(Ribbon.Manager, "Copy", 0);
BarButtonItem itemCut = new BarButtonItem(Ribbon.Manager, "Cut", 1);
groupFormat.ItemLinks.AddRange(new BarItem[] {itemCopy, itemCut});
contextPageFormat.Groups.Add(groupFormat);
// Subscribe to an event which fires when any item is clicked.
Ribbon.ItemClick += new ItemClickEventHandler(Ribbon_ItemClick);

// Add the RibbonControl to the form.
this.Controls.Add(Ribbon);

//...

// Make the Selection category visible
catSelection.Visible = true;
// Activate the category's first page.
Ribbon.SelectedPage = catSelection.Pages[0];


// Respond to item clicking.
void Ribbon_ItemClick(object sender, ItemClickEventArgs e) {
    //...
}

Inheritance

Object
MarshalByRefObject
Component
DevExpress.XtraBars.BaseBarComponent
DevExpress.XtraBars.Ribbon.BaseRibbonComponent
RibbonPageCategory
See Also