英文:
How to refresh whole ribbon (not just control)?
问题
我有一个 VSTO Office/Outlook 插件和功能区,我想在某个时候重新加载它。不幸的是,ribbon.invalidate 不适用于我的情况,因为它只会重新触发 getLabel 等方法,而我需要重新构建整个功能区/分组。
我需要强制执行 GetCustomUI() 方法。
您知道如何做吗?
英文:
I have an VSTO Office/Outlook add-in and ribbon that I want to reload at some point. Unfortunatelly ribbon.invalidate is not something that suits my case, because it just re-fires getLabel etc. methods, while I need to rebuild whole ribbon/group.
I need to force executing method GetCustomUI().
Do you know how can I do it?
答案1
得分: 3
没有办法强制Office应用程序调用GetCustomUI回调函数。如果您需要在启动时默认隐藏自定义功能区UI,您可以使用功能区控件的getVisible
回调,包括选项卡,以及在需要时可以调用IRibbonUI.Invalidate
来调用您的控件回调,这样您可以返回适当的值并在功能区上显示您的控件。
例如,如果插件作者为按钮实现了getVisible
回调过程,该函数在加载状态后被调用一次,然后如果需要更新状态,将使用缓存的状态而不是重新调用该过程。该过程保持不变,直到插件使用Invalidate
方法发信号表明缓存值无效为止,此时再次调用回调过程并缓存返回响应。然后,插件可以通过调用Refresh
方法强制立即更新UI。
英文:
There is no way to force Office applications invoke the GetCustomUI callback. If you need to keep your custom ribbon UI hidden at startup by default you can use the getVisible
callback for the ribbon controls, including tabs, and when required you may call the IRibbonUI.Invalidate
to get your controls callback invoked, so you could return an appropriate value and get your controls appeared on the ribbon.
For example, if an add-in writer implements the getVisible
callback procedure for a button, the function is called once, the state loads, and then if the state needs to be updated, the cached state is used instead of recalling the procedure. This process remains in place until the add-in signals that the cached values are invalid by using the Invalidate
method, at which time, the callback procedure is again called and the return response is cached. The add-in can then force an immediate update of the UI by calling the Refresh
method.
答案2
得分: 0
无法这样做 - 按设计,Ribbon 是静态的,即使一些控件最初可以隐藏,当它们的 getVisible
回调被调用时后来也可以显示。
请注意,控件内容可以动态填充(听起来这才是您实际想要的),这适用于 dropDown
控件。在这种情况下,您需要指定 getItemCount
/getItemLabel
/getItemImage
/getSelectedItemIndex
回调。
请参阅 MSDN 上的 dropDown
控件描述:https://learn.microsoft.com/en-us/openspecs/office_standards/ms-customui/700e4451-8706-40c5-8d7b--896e4ae21b69
英文:
No way to do that - by design, Ribbon is static, even though some controls can be hidden initially and be shown later when their getVisible
callback is invoked.
Note that control contents can be populated dynamically (sounds like that is what you actually want), that applies to the dropDown
control. In that case, you need to specify getItemCount
/getItemLabel
/getItemImage
/getSelectedItemIndex
callbacks.
See the dropDown
control description on MSDN: https://learn.microsoft.com/en-us/openspecs/office_standards/ms-customui/700e4451-8706-40c5-8d7b-896e4ae21b69
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论