Click or drag to resize
How to: RibbonControl

RibbonControl feature can be used to add a ribbon tab to a custom control. Most often, this feature is used to add a ribbon tab to whole site or site collection, by using Delegate control technique.

Creating a simple demo

  1. Create Empty SharePoint project in Visual Studio 2010.

  2. Add reference to FluentRibbon.dll

  3. Add FluentRibbon.dll into GAC deployment list (Package.package, 'Advanced' tab)

  4. Add [SharePoint -> 2010 -> User Control] project item to the project

  5. Inherit the newly created control from the RibbonControl class.

  6. Override the GetTabDefinition method, and provide tab definition for your custom ribbon tab.

  7. Use your control somewhere. It could be a webpart, page, delegate control.

  8. Deploy!

Example

Code example:

C#
public partial class TestRibbonControl : RibbonControl
{
    public override TabDefinition GetTabDefinition()
    {
        return new TabDefinition()
        {
            Id = "CommonTasks",
            Title = "Common tasks",
            Groups = new GroupDefinition[]
            {
                new GroupDefinition()
                {
                    Id = "Sample",
                    Title = "Sample",
                    Template = GroupTemplateLibrary.SimpleTemplate,
                    Controls = new ControlDefinition[]
                    {
                        ControlLibrary.CreateRandomButton()
                    }
                }
            }
        };
    }
}

The tab will appear following way on every page, where the control is presented.

Common Tasks Tab

So, it will be initially inactive. Also, there can be several controls, thus there could be several ribbon tabs on one page.

See Also