问题
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