VSTO RIBBON XML设置回调属性在' template'对于每种控制类型

发布于 2025-01-26 02:48:35 字数 2502 浏览 3 评论 0原文

我有一个使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七婞 2025-02-02 02:48:35

是的,有可能。使用.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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文