This project is read-only.

Adding a custom contextual group to the SharePoint Rbbon

Back to Walkthrough

This topic describes how to add a custom contextual group to the SharePoint Rbbon.

Defining the contextual webpart

To use contextual group create webpart derived from QASPRibbon.ContextualWebPart class:
using System.ComponentModel;
using QASPRibbon;
using QASPRibbon.Controls;

namespace QASPRibbonDemo.ContextualDemoWebPart
    public class ContextualDemoWebPart : ContextualWebPart
        public override RibbonContextualGroup GetContextualGroupDefinition()
            //TODO: define custom RibbonContextualGroup
            return null;

Defining the custom contextual group

Modify GetContextualGroupDefinition method:
public override RibbonContextualGroup GetContextualGroupDefinition()
    // ContextualGroup
    var contextualGroup = new RibbonContextualGroup("GroupId", "GroupTitle")
            Color = RibbonContextualColor.LightBlue
    // Tab
    var tab = new RibbonTab("TabId", "TabTitle");

    // Group            
    var group = new RibbonGroup("GroupId", "GroupTitle");
    // Section
    var section = new RibbonGroupSection
            Type = RibbonSectionType.OneRow,
            DisplayMode = RibbonDisplayMode.Image32AndCaption 

    // Button
    var button = new RibbonButton("ButtonId", "ButtonTitle")
            Image = RibbonImageDefinition.Standard15(2, 5),
            OnClientClick = "alert('ButtonId has been clicked!');"

    // Adding button to the section
    section.Controls = new RibbonControl[] {button};

    // Adding group to the section
    group.Sections = new RibbonGroupSection[] {section};

    // Adding group to the tab
    tab.Groups = new RibbonGroup[] {group};

    // Adding tab to the contextual group
    contextualGroup.Tabs = new RibbonTab[] {tab};

    return contextualGroup;

Color of contextual group can be set by using Color property.


Deploy solution and add webpart to the page.


Custom contextual group:

See also


Adding a custon tab to the SharePoint Rbbon



Contextual group' colors

Last edited Aug 25, 2013 at 1:11 PM by VitalyZhukov, version 11


No comments yet.