在XML功能区中以编程方式访问功能区元素 [英] Access Ribbon Elements Programmatically in XML Ribbon

查看:74
本文介绍了在XML功能区中以编程方式访问功能区元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里似乎已经被问了好几次了,没有真正的答案:

This seems to have been asked several times on here with no real answer:

在XML功能区中以编程方式访问功能区控件

Office功能区:使用XML创建功能区时如何访问控件

据我所知,如果使用功能区xml创建功能区,则不会以编程方式公开该xml中定义的组件.更改这些组件状态的唯一明显的有限方法是使用诸如onAction,getContent,getImage事件之类的东西,并且IRibbonControl元素几乎没有提供用于处理有问题的元素的功能(更不用说,大多数这些功能只能运行一次,首次呈现时).

If a ribbon is created using ribbon xml, as far as I can tell, there is no programmatic exposure of the components defined in that xml. The only obvious limited way to change the state of these components is to use something like an onAction, getContent, getImage event, and the IRibbonControl element offers very little for manipulating the element in question (not to mention, most of those functions only run once, when first rendered).

因此,我正在尝试找到一种以编程方式访问这些xml功能区元素的方法.

So I'm trying to find a way to programmatically access those xml ribbon elements.

推荐答案

使用Ribbon XML时,无法以编程方式访问Ribbon元素.如果要更改功能区控件的状态-您需要使用IRibbonUI.Invalidate()强制进行新的布局渲染(可能使用通过回调在渲染时触发不同行为的属性).这是一件好事,因为如果您更改多个项目的状态,则可以更好地控制何时进行绘制.

There is no way to programmatically access Ribbon elements when using Ribbon XML. If you want to change the state of the Ribbon controls - you need to use IRibbonUI.Invalidate() to force a new rendering of the layout (potentially using properties that trigger different behaviors at rendering time via callbacks). This can be a good thing as you have more control over when drawing occurs if you are changing multiple items' state.

有关更新Ribbon UI控件状态,请参见相关的SO帖子.

See related SO post on updating Ribbon UI control state.

如果要以编程方式访问Ribbon元素,则应使用 Ribbon Designer .但是,如MSDN上所述,设计器不支持全部定制.一些推测设计师只是为您包装了Ribbon XML 引擎盖.

If you want programmatic access to Ribbon elements, you should use the Ribbon Designer. However, as stated on MSDN, the designer doesn't support all customizations. Some speculate that the designer just wraps the Ribbon XML up for you under the hood.

您只需要学习Ribbon XML使用的回调机制-没有控制树供您访问.

You just have to learn the callback mechanism utilized by the Ribbon XML - there is no control tree for you to gain access to.

这篇关于在XML功能区中以编程方式访问功能区元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆