Ribbon button not firing event set by onAction when clicked

余生长醉 提交于 2019-12-23 08:58:11

问题


I've designed an add-in to Outlook 2010 where I'm trying to fire (or, rather, catch) an event fired when a button is clicked as shown in this article. I've targeted the right XML (since the changes to it are seen on the ribbon). However, The event I'm trying to catch is either not fired at all or (more likely) fired an other way than what my listened is looking (listening?).

I also tried to go by the reference on MSDN here, here and mostly here. To no avail, though... I wonder if it's got to do with the "repurpose" information.

Here's the markup.

<tab idMso="TabMail">
  <group id="group1" label="CRMK">
    <button 
      id="MyId"
      onAction="Button_Click"
      label="Do me!"
      size="large" />
  </group>
  <group id="group2" label="group2">
    <button id="button1" label="button1" showImage="false" />
  </group>
</tab>

And the code behind looks like this.

private void Button_Click(Object sender, RibbonControlEventArgs eventArgs)
{
  MessageBox.Show("Button clicked...");
}

What am I missing? How can I debug such a thing?


回答1:


This is because of your signature. It's wrong for ribbon objects. It should be as follows.

public void Button_Click(Office.IRibbonControl control){ ... }


来源:https://stackoverflow.com/questions/12674575/ribbon-button-not-firing-event-set-by-onaction-when-clicked

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!