Elements 元素(自定义操作)

上次修改时间: 2015年3月9日

适用范围: SharePoint Foundation 2010

本文内容
属性
子元素
父元素

包含功能元素声明的功能清单文件中的顶级元素。

<Elements
  Id = "Text">
</Elements>

属性

属性

说明

xmlns

必需。标识 XML 命名空间。其值必须为 https://schemas.microsoft.com/sharepoint/。

Id

可选属性,类型为 Text。指定功能清单文件的唯一标识符。

子元素

CustomAction

CustomActionGroup

HideCustomAction

父元素

示例

下面的示例定义一个向服务器功能区中添加按钮的自定义操作。

<Elements xmlns="https://schemas.microsoft.com/sharepoint/">
  <CustomAction 
    Id="Ribbon.Library.Actions.AddAButton"
    Location="CommandUI.Ribbon"
    RegistrationId="101"
    RegistrationType="List"
    Title="Add a Ribbon Button">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition
          Location="Ribbon.Library.Share.Controls._children">
          <Button Id="Ribbon.Library.Share.NewRibbonButton"
            Command="NewRibbonButtonCommand"
            Image16by16="Insert an image URL here."
            Image32by32="Insert an image URL here."
            LabelText="Hello World"
            TemplateAlias="o2" />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler 
          Command="NewRibbonButtonCommand"
          CommandAction="javascript:alert('Hello, world');" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>