适用于: SharePoint 2016 |SharePoint Foundation 2013 |SharePoint Online |SharePoint Server 2013
表示 GroupTemplate 元素中某控件的占位符。
<ControlRef
  DisplayMode="Small | Medium | Large | Menu | Menu16 | Menu32"
  TemplateAlias="Text"
/>
元素和属性
下面各部分介绍了属性、子元素和父元素。
Attributes
| 属性 | 说明 | 
|---|---|
| DisplayMode | 可选。 一个枚举值,该值确定控件的呈现方式: - 小。 呈现为不带标签文本的小图标。 - 中等。 呈现为带标签文本的 16 X 16 像素图标。 - 大。 呈现为带标签文本的 32 X 32 像素图标。 - 菜单。 呈现为纯文本菜单项。 - Menu16。 呈现为带 16 X 16 像素图标的菜单项。 - Menu32。 呈现为带 32 X 32 像素图标的菜单项。 | 
| TemplateAlias | 可选。 一个控件可在其自己的 TemplateAlias 属性中引用的字符串。 在对某个组应用模板时,可使用 TemplateAlias 属性调整该组中控件的大小和位置。 同一 GroupTemplate 元素包含的任何两个元素都不能具有相同的 TemplateAlias 值。 | 
子元素
无
父元素
出现次数
- 最小值:0
- 最大值:无限制
备注
控件不一定支持所有显示模式。 下表列出了各个类型的控件支持的模式。
| Control | Small | Medium | Large | 菜单 | Menu16 | Menu32 | 
|---|---|---|---|---|---|---|
| Button | X | X | X | X | X | X | 
| CheckBox | X | X | ||||
| ColorPicker | X | |||||
| ComboBox | X | |||||
| DropDown | X | |||||
| FlyoutAnchor | X | X | X | X | X | X | 
| GalleryButton | X | X | ||||
| InsertTable | X | |||||
| Label | X | X | ||||
| MenuSection | X | X | ||||
| MRUSplitButton | X | X | X | |||
| 缓冲图标 | X | |||||
| SplitButton | X | X | X | |||
| TextBox | X | |||||
| ToggleButton | X | X | X | 
示例
下面的示例是一个 XML 片段,演示 Group 元素中控件的 TemplateAlias 属性和 GroupTemplate 元素中 ControlRef 元素的相同属性之间的关系。
请注意,Group 元素包含三个 Button 元素,每个元素的 TemplateAlias 属性设置为 、 "row2"或 "row3"值"row1"。
GroupTemplate 元素还包含三个 ControlRef 元素,这些元素的属性设置为 、 "row2"或 "row3"值"row1"。
在将模板应用到该组时,将通过匹配 Button 元素的 TemplateAlias 属性和 ControlRef 元素的 TemplateAlias 属性来确定控件在组中的布局。
<Group
  Id="Ribbon.CustomTabExample.CustomGroupExample"
  Description="This is a custom group."
  Title="Custom Group"
  Sequence="52"
  Template="Ribbon.Templates.CustomTemplateExample">
  <Controls Id="Ribbon.CustomTabExample.CustomGroupExample.Controls">
    <Button
      Id="Ribbon.CustomTabExample.CustomGroupExample.HelloWorld"
      Command="CustomTabExample.HelloWorldCommand"
      Sequence="15"
      Description="Says hello to the World!"
      LabelText="Hello!"
      TemplateAlias="row1"/>
    <Button
      Id="Ribbon.CustomTabExample.CustomGroupExample.GoodbyeWorld"
      Command="CustomTabExample.GoodbyeWorldCommand"
      Sequence="17"
      Description="Says goodbye to the World!"
      LabelText="Goodbye!"
      TemplateAlias="row2"/>
    <Button
      Id="Ribbon.CustomTabExample.CustomGroupExample.LaterWorld"
      Command="CustomTabExample.LaterWorldCommand"
      Sequence="19"
      Description="Says I will see you later to the World!"
      LabelText="Later!"
      TemplateAlias="row3"/>
  </Controls>
</Group>
<GroupTemplate Id="Ribbon.Templates.CustomTemplateExample">
  <Layout
    Title="OneLargeTwoMedium"
    LayoutTitle="OneLargeTwoMedium">
    <Section Alignment="Top" Type="OneRow">
      <Row>
        <ControlRef DisplayMode="Large" TemplateAlias="row1" />
      </Row>
    </Section>
    <Section Alignment="Top" Type="TwoRow">
      <Row>
        <ControlRef DisplayMode="Medium" TemplateAlias="row2" />
      </Row>
      <Row>
        <ControlRef DisplayMode="Medium" TemplateAlias="row3" />
      </Row>
    </Section>
  </Layout>
</GroupTemplate>