功能区控件不会出现

时间:2014-05-25 14:59:15

标签: sharepoint sharepoint-2010

我确实尝试创建一个带有2个控件的功能区选项卡,即一个按钮,当用户点击它时触发弹出消息,第二个是文本框。标签出现了。但是,组和功能区控件没有,只显示加载状态。我不知道我缺少哪些元素或属性。你可以查看我的代码并告诉我你是否看到了这个问题。

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
    Id="Begin.CustomAction"
    Location="CommandUI.Ribbon"
    RegistrationId="101"
    RegistrationType="List"
    >
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.Tabs._children" >
          <Tab Id="Begin.Tab"
               Sequence="550"
               Title="My Ribbon tab">
            <Scaling Id="Begin.Scaling">
              <MaxSize Id="Begin.MaxSize" Size="OneLarge" GroupId ="Begin.Mygroup"/>
              <Scale Id="Begin.Scale.tab" Size="OneLarge" GroupId="Begin.MyGroup"/>
            </Scaling>
            <Groups Id="Begin.Groups">
              <Group Id="Begin.MyGroup" Description="This is my first Group" Title="Ribbon Group">
                <Controls Id="Begin.Controls">
                  <Button Id="Begin.Controls.HelloWorldButton"
                          Command="HelloWorld"
                          Description="Click here to show message"
                          LabelText="Hello World"
                          TemplateAlias="cust1"
                          Sequence="15"
                          />
                  <TextBox Id="Begin.Controls.NameTextBox" 
                           TemplateAlias="cust2"
                           Sequence="15"
                           />
                </Controls>
              </Group>
            </Groups>
          </Tab>
        </CommandUIDefinition>
        <CommandUIDefinition Location="Ribbon.Templates._children">
          <GroupTemplate Id="Begin.GroupTemplate.TwoMediumRow">
            <Layout Title="TwoLarge" LayoutTitle="TwoLarge">
              <Section Alignment="Top" Type="OneRow">
                <Row>
                  <ControlRef DisplayMode="Medium" TemplateAlias="cust1"/>
                  <ControlRef DisplayMode="Medium" TemplateAlias="cust1"/>
                </Row>
              </Section>
            </Layout>
          </GroupTemplate>
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler Command="HelloWorld" CommandAction="javascript:alert('Hello world');">
        </CommandUIHandler>
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>

1 个答案:

答案 0 :(得分:-1)

您可以尝试以下代码示例:

Elements.xml的

    <?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
    Id="Begin.CustomAction"
    Location="CommandUI.Ribbon"
    RegistrationId="101"
    RegistrationType="List"
    >
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.Tabs._children" >
          <Tab Id="Begin.Tab"
               Sequence="550"
               Title="My Ribbon tab">
            <Scaling Id="Begin.Scaling">
              <MaxSize Id="Begin.MaxSize" Size="TwoLarge" GroupId ="Begin.MyGroup"/>
              <Scale Id="Begin.Scale.tab" Size="TwoLarge" GroupId="Begin.MyGroup"/>
            </Scaling>
            <Groups Id="Begin.Groups">
              <Group Id="Begin.MyGroup" Description="This is my first Group" Title="Ribbon Group" Template="Begin.GroupTemplate.TwoMediumRow">
                <Controls Id="Begin.Controls">
                  <Button Id="Begin.Controls.HelloWorldButton"
                          Command="HelloWorld"
                          Description="Click here to show message"
                          LabelText="Hello World"
                          TemplateAlias="cust1"
                          Sequence="15"
                          />
                  <TextBox Id="Begin.Controls.NameTextBox"
                           TemplateAlias="cust2"
                           Sequence="15"
                           />
                </Controls>
              </Group>
            </Groups>
          </Tab>
        </CommandUIDefinition>
        <CommandUIDefinition Location="Ribbon.Templates._children">
          <GroupTemplate Id="Begin.GroupTemplate.TwoMediumRow">
            <Layout Title="TwoLarge" LayoutTitle="TwoLarge">
              <Section Alignment="Top" Type="OneRow">
                <Row>
                  <ControlRef DisplayMode="Medium" TemplateAlias="cust1"/>
                  <ControlRef DisplayMode="Medium" TemplateAlias="cust2"/>
                </Row>
              </Section>
            </Layout>
          </GroupTemplate>
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler Command="HelloWorld" CommandAction="javascript:alert('Hello world');">
        </CommandUIHandler>
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>

供参考: http://msdn.microsoft.com/en-us/library/office/ff407250(v=office.14).aspx