开发者

Outlook 2007 Ribbon and MVP

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 Gl开发者_StackOverflow社区obals.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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜