触发对 IRibbonExtensibility.GetCustomUI() 的调用以强制功能区 UI 刷新

发布于 2024-12-20 11:06:39 字数 253 浏览 1 评论 0原文

我正在开发一个 Office 加载项。由于功能区控件的一些限制(例如 menuSeparator 没有可见性控件或 splitButton 无法托管 dynamicMenu,只能托管 menu),我需要能够通过重复调用加载项的 IRibbonExtensibility.GetCustomUI 来使 Office 应用重新加载功能区。

这可能吗?

I am developing an Office add-in. Due to some limitations of ribbon controls (e.g. menuSeparator has no visibility control or splitButton cannot host a dynamicMenu only a menu), I need to be able to cause the Office app to reload the ribbon by repeating a call to my add-in's IRibbonExtensibility.GetCustomUI.

Is this possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

转瞬即逝 2024-12-27 11:06:39

据我所知,功能区加载项需要停止然后重新启动加载项。鉴于人们可以访问 Outlook 中的加载项列表,必须有一种方法可以做到这一点。您可以运行加载项的另一个实例,该实例将首先关闭前一个实例,然后返回更新的功能区 XML。但这意味着当用户单击功能区的组件时它不适用,并且您必须将所有数据保存在某处,然后读取它以恢复加载项状态。此外,用户可能会看到丝带消失并再次出现,这可能是不受欢迎的。

As far as I know ribbon add-ins, this would require to stop and then restart your add-in. There must be a way to do so given that one can access the list of add-ins in outlook. you could run another instance of your add-in which would first close the previous one, then return the updated ribbon XML. But this means that it would not be applicable while the user is clicking on the ribbon's components, and you would have to save all your data somewhere and then read it to restore the add-in status. In addition, the user may see the ribbon disapearing and appearing again, which may not be appreciated.

梦冥 2024-12-27 11:06:39

Ribbon.Invalidate() 方法适合您的用例吗?当我动态添加/删除项目时,我经常使用它来刷新功能区。

例如,在 Ribbon c# 文件(默认为 Ribbon1.cs)中:

this.ribbon.Invalidate();

当需要刷新功能区时。这假设您已在 Ribbon_Load 方法中设置了 this.ribbon。

Would the Ribbon.Invalidate() method work for your use case? I frequently use it to refresh the ribbon when I've dynamically added/removed items.

For example, in the Ribbon c# file (Ribbon1.cs by default):

this.ribbon.Invalidate();

When the ribbon needs to be refreshed. This assumes you've set this.ribbon in the Ribbon_Load method.

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