Getting started |
Ribbon is a central SharePoint 2010 feature, but for developer it is not so handy, as for a user.
This project aims to provide fluent API for Ribbon creation and managing in SharePoint 2010.
This project contains following main features:
ContextualWebPart - base class for webparts with contextual ribbon tabs
RibbonLayoutsPage - base class for Application Pages with ribbon
RibbonControl - base class for delegate controls with ribbon
RibbonCustomAction - provision ribbon with Fluent Ribbon definition classes (alternative to SharePoint XML provisioning)
Here is a little how-to on using FluentRibbon project in your custom ribbon projects.
Add reference to FluentRibbon.dll from your SharePoint project
Include FluentRibbon.dll in Package.package for GAC deploying ('Advanced' tab).
Inherit either your webpart class or Application Page code behind class from corresponding FluentRibbon classes.
Override ribbon definition method (GetContextualGroupDefinition or GetTabDefinition), and provide ribbon definition to FluentRibbon.
Deploy!
Definition classes are well-documented, so you'll get intellisense and summary notes on each property.
For example, button definition could look like this:
new ButtonDefinition() { Id = "New", Title = "Start new game", CommandJavaScript = "window.location.reload();", Image = new ImageDefinition() { Url16 = "/_layouts/images/ChessWebPart/new16.png", Url32 = "/_layouts/images/ChessWebPart/new32.png" } }
This code will result in following ribbon button:
Also, you can partially use FluentRibbon with sandboxed solutions and SharePoint Online (Office365). By now, only the RibbonCustomAction feature is supported.
For this purpose, you should use FluentRibbon.Sandboxed.dll instead of FluentRibbon.dll. For details, please see article about RibbonCustomAction.