访问带状元件通过编程方式在XML丝带 [英] Access Ribbon Elements Programatically in XML Ribbon

查看:131
本文介绍了访问带状元件通过编程方式在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 programatically access those xml ribbon elements.

推荐答案

有没有办法使用功能区XML时以编程方式访问带状元件。如果要更换色带控件的状态 - 你需要使用 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.

请参阅相关SO帖子上更新的Ribbon UI控制状态。

See related SO post on updating Ribbon UI control state.

如果你想丝带元素的编程访问,你应该使用功能区设计。然而,由于 MSDN上的所述,设计师并不支持所有自定义。一些推测,设计师只是包装引擎盖下的功能区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.

您只要学会使用的回调机制通过功能区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天全站免登陆