public override TabDefinition GetTabDefinition() { var controls = new List <ControlDefinition>(); controls.Add(ControlLibrary.CreateRandomButton()); controls.Add(new ButtonDefinition() { Id = controls[0].Id, TemplateAlias = controls[0].TemplateAlias, Title = "Hi" }); if (SPContext.Current.Web.CurrentUser.IsSiteAdmin) { controls.Add(ControlLibrary.CreateRandomButton()); } return(new TabDefinition() { Id = "CommonTasks", Title = "Common tasks", Groups = new GroupDefinition[] { new GroupDefinition() { Id = "Sample", Title = "Sample", Template = GroupTemplateLibrary.SimpleTemplate, Controls = controls.ToArray() } } }); }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPWeb web = (properties.Feature.Parent as SPSite).RootWeb; var button1 = ControlLibrary.CreateRandomButton(); var ribbonCustomAction = new RibbonCustomAction(); // We need assign TemplateAlias manually to buttons, if they will be deployed separately button1.TemplateAlias = "o1"; ribbonCustomAction.AddControl(button1, "Ribbon.ListItem.New", 1); ribbonCustomAction.Provision(properties.Feature.DefinitionId, web, ListTypes.GenericList); }
public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPSite site = properties.Feature.Parent as SPSite; var buttonDelete = ControlLibrary.StandardButtons.ListItem.Manage_Delete(""); buttonDelete.Title = "Remove"; var buttonNew = new ButtonDefinition() { Id = "NewProject", Title = "New", }; var group = new GroupDefinition() { Id = "MyGroup", Title = "Custom controls", Template = Libraries.GroupTemplateLibrary.SimpleTemplate, Controls = new ControlDefinition[] { buttonNew, buttonDelete } }; var ribbonCustomAction = new RibbonCustomAction(); ribbonCustomAction.AddControlGroup(group, SPRibbonIds.ListItem.Id, 25); ribbonCustomAction.RemoveRibbonElement(SPRibbonIds.ListItem.Groups.New.Id); // We need assign TemplateAlias manually to buttons, if they will be deployed separately var button1 = ControlLibrary.CreateRandomButton(); button1.TemplateAlias = "o1"; ribbonCustomAction.AddControl(button1, SPRibbonIds.ListItem.Groups.Manage.Id, 1); ribbonCustomAction.Provision(properties.Definition.Id, site, ListTypes.GenericList); }