Home > sharepoint, sharepoint 2010 > Creating FlyoutAnchor in SharePoint 2010 ribbon

Creating FlyoutAnchor in SharePoint 2010 ribbon

December 23rd, 2009
Share this on Twitter

For the past few articles I`ve been discussing working with ribbon and creating your custom controls. It literally is possible to create any control you see in out of the box ribbon. In this post I`d like to demonstrate how to work with rather interesting control called FlyoutAnchor.

FlyoutAnchor is a button which opens another collection of buttons when you click on it; when you click on those other buttons – they are actually ones that will execute custom action – in my case display a message.

Take a look at the below ribbon definition below, also available to you as a Visual Studio 2010 solution here

NOTE: To run this sample after you deployed the solution, create a new document library and look for new FlyoutAnchor in Share section of a Library tab inside your document library, it will look something like this:

flyoutanchor

<?xml version=”1.0″ encoding=”utf-8″?>
<Elements xmlns=”http://schemas.microsoft.com/sharepoint/”>
<CustomAction
Id=”Ribbon.Library.Share.FlyoutAnchorSample”
Location=”CommandUI.Ribbon”
RegistrationId=”101″
RegistrationType=”List”
Title=”Using FlyoutAnchor”>
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition
Location=”Ribbon.Library.Share.Controls._children”>
<FlyoutAnchor
Id=”Ribbon.Library.Share.FlyoutAnchor”
Sequence=”20″
LabelText=”My Flyout Anchor”
Image16by16=”/_layouts/images/QuickTagILikeIt_16.png”
TemplateAlias=”o1″>
<Menu Id=”Ribbon.Library.Share.FlyoutAnchor.Menu”>
<MenuSection Id=”Ribbon.Library.Share.FlyoutAnchor.Menu.MenuSection” Sequence=”10″ DisplayMode=”Menu16″>
<Controls Id=”Ribbon.Library.Share.FlyoutAnchor.Menu.MenuSection.Controls”>
<Button
Id=”Ribbon.Library.Share.FlyoutAnchor.Menu.MenuSection.MyButton”
Sequence=”10″
Command=”NewRibbonButtonCommand”
LabelText=”MyButton”
Image16by16=”/_layouts/images/QuickTagILikeIt_16.png”
TemplateAlias=”o2″
/>
</Controls>
</MenuSection>
<MenuSection Id=”Ribbon.Library.Share.FlyoutAnchor.Menu.MenuSection1″ Sequence=”20″ DisplayMode=”Menu16″>
<Controls Id=”Ribbon.Library.FlyoutAnchor.Menu.MenuSection1.Controls”>
<Button
Id=”Ribbon.Library.FlyoutAnchor.Menu.MenuSection1.MyButton1″
Sequence=”10″
Command=”NewRibbonButtonCommand”
LabelText=”MyButton1″
Image16by16=”/_layouts/images/QuickTagILikeIt_16.png”
TemplateAlias=”o3″
/>
</Controls>
</MenuSection>
</Menu>
</FlyoutAnchor>
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command=”NewRibbonButtonCommand”
CommandAction=”javascript:HelloRibbon();” />
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
<CustomAction Id=”Ribbon.Library.Share.FlyoutAnchorSample.Script”
Location=”ScriptLink”
ScriptBlock=”
function HelloRibbon()
{
alert(’Hello there, Ribbon!’);
}” />
</Elements>

<?xml version=”1.0″ encoding=”utf-8″?>

<Elements xmlns=”http://schemas.microsoft.com/sharepoint/”>

<CustomAction

Id=”Ribbon.Library.Share.FlyoutAnchorSample”

Location=”CommandUI.Ribbon”

RegistrationId=”101″

RegistrationType=”List”

Title=”Using FlyoutAnchor”>

<CommandUIExtension>

<CommandUIDefinitions>

<CommandUIDefinition

Location=”Ribbon.Library.Share.Controls._children”>

<FlyoutAnchor

Id=”Ribbon.Library.Share.FlyoutAnchor”

Sequence=”20″

LabelText=”My Flyout Anchor”

Image16by16=”/_layouts/images/QuickTagILikeIt_16.png”

TemplateAlias=”o1″>

<Menu Id=”Ribbon.Library.Share.FlyoutAnchor.Menu”>

<MenuSection Id=”Ribbon.Library.Share.FlyoutAnchor.Menu.MenuSection” Sequence=”10″ DisplayMode=”Menu16″>

<Controls Id=”Ribbon.Library.Share.FlyoutAnchor.Menu.MenuSection.Controls”>

<Button

Id=”Ribbon.Library.Share.FlyoutAnchor.Menu.MenuSection.MyButton”

Sequence=”10″

Command=”NewRibbonButtonCommand”

LabelText=”MyButton”

Image16by16=”/_layouts/images/QuickTagILikeIt_16.png”

TemplateAlias=”o2″

/>

</Controls>

</MenuSection>

<MenuSection Id=”Ribbon.Library.Share.FlyoutAnchor.Menu.MenuSection1″ Sequence=”20″ DisplayMode=”Menu16″>

<Controls Id=”Ribbon.Library.FlyoutAnchor.Menu.MenuSection1.Controls”>

<Button                  Id=”Ribbon.Library.FlyoutAnchor.Menu.MenuSection1.MyButton1″

Sequence=”10″

Command=”NewRibbonButtonCommand”

LabelText=”MyButton1″

Image16by16=”/_layouts/images/QuickTagILikeIt_16.png”

TemplateAlias=”o3″

/>

</Controls>

</MenuSection>

</Menu>

</FlyoutAnchor>

</CommandUIDefinition>

</CommandUIDefinitions>

<CommandUIHandlers>

<CommandUIHandler

Command=”NewRibbonButtonCommand”

CommandAction=”javascript:HelloRibbon();” />

</CommandUIHandlers>

</CommandUIExtension>

</CustomAction>

<CustomAction Id=”Ribbon.Library.Share.FlyoutAnchorSample.Script”

Location=”ScriptLink”

ScriptBlock=”

function HelloRibbon()

{

alert(’Hello there, Ribbon!’);

}” />

</Elements>

Enjoy!

Yaroslav Pentsarskyy sharepoint, sharepoint 2010 , , ,

You must be logged in to post a comment.