VSTO RIBBON XML设置回调属性在' template'对于每种控制类型
我有一个使用XML的C#VSTO Excel加载项。在其中,有多个toggleButtons都使用与其“ getLabel”,“ getKeytip”,“ getScreentip”,“ getSupertip”,“ getperspressed”,“ getPressed”和“ getPressed”和“ getPressed”和& amp; amp; amp;&&中; “ antaction”回调。这些功能然后返回正确的值或基于控件的ID执行正确的代码。
是否可以为这些设置这些属性但允许我提供ID的元素创建一个“模板”?
例如,这就是我目前拥有的:
<toggleButton
id="tb1"
getLabel="GetLabel"
getKeytip="GetKeytip"
getScreentip="GetScreentip"
getSupertip="GetSupertip"
getPressed="Togglebutton_GetPressed"
onAction="Togglebutton_OnAction"/>
<toggleButton
id="tb2"
getLabel="GetLabel"
getKeytip="GetKeytip"
getScreentip="GetScreentip"
getSupertip="GetSupertip"
getPressed="Togglebutton_GetPressed"
onAction="Togglebutton_OnAction"/>
<toggleButton
id="tb3"
getLabel="GetLabel"
getKeytip="GetKeytip"
getScreentip="GetScreentip"
getSupertip="GetSupertip"
getPressed="Togglebutton_GetPressed"
onAction="Togglebutton_OnAction"/>
<toggleButton
id="tb4"
getLabel="GetLabel"
getKeytip="GetKeytip"
getScreentip="GetScreentip"
getSupertip="GetSupertip"
getPressed="Togglebutton_GetPressed"
onAction="Togglebutton_OnAction"/>
<toggleButton
id="tb5"
getLabel="GetLabel"
getKeytip="GetKeytip"
getScreentip="GetScreentip"
getSupertip="GetSupertip"
getPressed="Togglebutton_GetPressed"
onAction="Togglebutton_OnAction"/>
我希望能够指定一个“模板”:
<toggleButtonTemplate
getLabel="GetLabel"
getKeytip="GetKeytip"
getScreentip="GetScreentip"
getSupertip="GetSupertip"
getPressed="Togglebutton_GetPressed"
onAction="Togglebutton_OnAction"/>
然后将我的功能区XML更新到类似的内容:
<toggleButtonTemplate
id="tb1"/>
<toggleButtonTemplate
id="tb2"/>
<toggleButtonTemplate
id="tb3"/>
<toggleButtonTemplate
id="tb4"/>
<toggleButtonTemplate
id="tb5"/>
类似的可能吗?如果是这样,我该怎么做?
I have a C# VSTO Excel add-in that uses XML for the ribbon. In it, there are multiple ToggleButtons that all use the same functions used in their 'getLabel', 'getKeytip', 'getScreentip', 'getSupertip', 'getPressed', & 'onAction' callbacks. Those functions then return the correct value or execute the correct code based on the control's ID.
Is it possible to create a 'template' for these elements that sets these attributes, but allows me to provide the ID?
For example here is what I currently have:
<toggleButton
id="tb1"
getLabel="GetLabel"
getKeytip="GetKeytip"
getScreentip="GetScreentip"
getSupertip="GetSupertip"
getPressed="Togglebutton_GetPressed"
onAction="Togglebutton_OnAction"/>
<toggleButton
id="tb2"
getLabel="GetLabel"
getKeytip="GetKeytip"
getScreentip="GetScreentip"
getSupertip="GetSupertip"
getPressed="Togglebutton_GetPressed"
onAction="Togglebutton_OnAction"/>
<toggleButton
id="tb3"
getLabel="GetLabel"
getKeytip="GetKeytip"
getScreentip="GetScreentip"
getSupertip="GetSupertip"
getPressed="Togglebutton_GetPressed"
onAction="Togglebutton_OnAction"/>
<toggleButton
id="tb4"
getLabel="GetLabel"
getKeytip="GetKeytip"
getScreentip="GetScreentip"
getSupertip="GetSupertip"
getPressed="Togglebutton_GetPressed"
onAction="Togglebutton_OnAction"/>
<toggleButton
id="tb5"
getLabel="GetLabel"
getKeytip="GetKeytip"
getScreentip="GetScreentip"
getSupertip="GetSupertip"
getPressed="Togglebutton_GetPressed"
onAction="Togglebutton_OnAction"/>
And I'd like to be able to specify a 'template':
<toggleButtonTemplate
getLabel="GetLabel"
getKeytip="GetKeytip"
getScreentip="GetScreentip"
getSupertip="GetSupertip"
getPressed="Togglebutton_GetPressed"
onAction="Togglebutton_OnAction"/>
And then have my ribbon XML be updated to something like:
<toggleButtonTemplate
id="tb1"/>
<toggleButtonTemplate
id="tb2"/>
<toggleButtonTemplate
id="tb3"/>
<toggleButtonTemplate
id="tb4"/>
<toggleButtonTemplate
id="tb5"/>
Is something like this possible? If so, how would I go about doing it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,有可能。使用.NET BCL处理XML文件。您可以在运行时生成功能区XML,然后使用 xmldocument
system.xml
namespace的类。参见将属性添加到XML节点以获取更多信息。Yes, it is possible. Use .net BCL for dealing with XML files. You can generate the ribbon XML at runtime and add attributes to the XML files dynamically using the XmlDocument class from the
System.XML
namespace. See Adding attributes to an XML node for more information.