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.
Create Empty SharePoint project in Visual Studio 2010.
Add reference to FluentRibbon.dll
Add FluentRibbon.dll into GAC deployment list (Package.package, 'Advanced' tab)
Add [SharePoint -> 2010 -> User Control] project item to the project
Inherit the newly created control from the RibbonControl class.
Override the GetTabDefinition method, and provide tab definition for your custom ribbon tab.
Use your control somewhere. It could be a webpart, page, delegate control.
Deploy!
Code example:
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.
So, it will be initially inactive. Also, there can be several controls, thus there could be several ribbon tabs on one page.