Outlook 2007 功能区和 MVP
我正在使用 Outlook 2007 VSTO Addin。我添加了一个带有按钮的功能区。我正在尝试在单击按钮时引发一个事件。在 Application.Inspectors 集合的 NewInspector 事件上,我应该能够在演示器中挂载到此功能区事件。
问题是如何获得打开的检查员功能区。我尝试了 Globals.Ribbons.MyRibbon 来执行此操作。奇怪的是,它仅适用于第一个检查员。我还尝试了 Globals.Ribbons[inspector].MyRibbon。
看起来创建 NewInspector 时,功能区集合有 0 个项目,并且仅在执行 NewInspector 事件处理程序后才会发生功能区加载。
是否有任何事件可以知道功能区何时加载,或者是否有任何替代方法,我可以将业务逻辑保留在 Presenter 中,而不是将其放在功能区视图中。
I'm working on outlook 2007 VSTO Addin.I have added a Ribbon with a button. I am trying to raise an event on button click.On NewInspector event of Application.Inspectors collection I should be able to hook on to this ribbon event in the Presenter.
The questions is how to get hold of Ribbon of Inspector opened. I tried Globals.Ribbons.MyRibbon
to do so.Strangely it works only for the first inspector. I also tried Globals.Ribbons[inspector].MyRibbon
.
Looks like when NewInspector is created the Ribbons Collection has 0 Items and Ribbon load happen only after NewInspector event handler is executed.
Is there any event to know when a ribbon loads OR Is there any alternative way ,where i can keep the business logic in Presenter instead of having it in ribbon view.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案是需要付出很大的努力。
据我所知,功能区没有通过 vsto 或 com 互操作公开,它也是无状态的,因此无论显示多少个检查员,功能区都会加载一次。
我花了很长时间才优雅地解决这个问题,而且代码相当复杂。我还应该提到,我选择使用功能区 XML 而不是设计器来解决问题,我发现设计器限制太多。
其核心是您必须创建一个自定义 IRibbonExtensibility 实现,然后重写功能区 XML 中的回调,以便它们回调到您的 IRibbonExtensibility impl 上的方法。
然后,您必须处理已加载的事件和新的检查器事件,以便可以将两者关联起来。
实际上还有很多内容,您可以在 VSTO contrib 项目中查看我的代码。
http://vstocontrib.codeplex.com /SourceControl/changeset/view/b35f26fdca15#src%2fOutlook.Utility%2fRibbonFactory%2fRibbonFactory.cs
如果您正在为 VSTO 构建 MVP 框架,请给我写信,因为我很想看看您在做什么。
The answer is with much effort..
As far as I can tell the ribbon is not exposed through vsto or com interop, it is also stateless, so the ribbon will be loaded once no matter how many inspectors are shown.
It took me a long time to gracefully solve this issue, and it is pretty complex code. I also should mention that I chose to tackle the problem using ribbon XML rather than the designer, I found the designer too restrictive.
The guts of it is you have to create a custom IRibbonExtensibility implementation, then rewrite the callbacks in the ribbon XML, so they will callback to methods on your IRibbonExtensibility impl.
You then have to handle the loaded event, and the new inspector event so you can relate the two.
There is actually a lot more to it and you can check out my code in the VSTO contrib project.
http://vstocontrib.codeplex.com/SourceControl/changeset/view/b35f26fdca15#src%2fOutlook.Utility%2fRibbonFactory%2fRibbonFactory.cs
If you are building a MVP framework for VSTO drop me an line as I would be interested to see what you are doing.