更新时间:2022-12-11 16:41:58
idQ
是正确的方法.此属性允许您指定合格的ID,即命名空间中的ID.内置了某些名称空间(例如mso
),但也可以指定自定义名称空间.
idQ
is the right way to go. This attribute allows you specify a qualified id, i.e. an id within a namespace. Some namespaces such as mso
are built in, but custom namespaces can also be specified.
关键是在customUI
元素中需要一个xmlns:foo="bar"
属性,该属性与您要扩展的第3方加载项的customUI
中声明的名称空间匹配.
The key is that you need a xmlns:foo="bar"
attribute in your customUI
element that matches the namespace declared within the customUI
of the 3rd party add-in you are trying to extend.
例如,假设我具有以下第3方加载项的XML:
For example, suppose I have the XML for the following 3rd party add-in:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<mso:customUI xmlns:mso="http://schemas.microsoft.com/office/2009/07/customui"
xmlns:foo="bar">
<mso:ribbon>
<mso:tabs>
<mso:tab idQ="foo:someTab" label="an extensible custom tab">
<mso:group id="someGroup" label="a custom group">
<mso:button id="someButton" label="button" />
</mso:group>
</mso:tab>
</mso:tabs>
</mso:ribbon>
</mso:customUI>
现在,我想用另一个加载项或模板中的新组扩展现有的foo:someTab
.我在新的外接程序中定义了customUI
,确保在customUI
元素中指定相同的名称空间属性.然后,我使用idQ="foo:someTab"
引用现有标签:
Now, I want to extend the existing foo:someTab
with a new group in another add-in or template. I define a customUI
in the new add-in, making sure to specify the same namespace attribute in the customUI
element. I then reference the existing tab using idQ="foo:someTab"
:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<mso:customUI xmlns:mso="http://schemas.microsoft.com/office/2009/07/customui"
xmlns:foo="bar">
<mso:ribbon>
<mso:tabs>
<mso:tab idQ="foo:someTab" label="an extensible custom tab">
<mso:group id="someOtherGroup" label="a different custom group">
<mso:button id="someOtherButton" label="a different button" />
</mso:group>
</mso:tab>
</mso:tabs>
</mso:ribbon>
</mso:customUI>
这将在一个自定义标签上产生两个组.可以使用相同的方法来扩展组和其他容器控件.
This results two groups on a single custom tab. The same approach can be used to extend groups and other container controls.
我通过仔细研究 Office 2010 Ribbon UI XSD .不幸的是,它在XSD本身之外的文档很少.
I learned this through careful study of the Office 2010 Ribbon UI XSD. Unfortunately, it's poorly documented outside of the XSD itself.