title: Excel VSTO addin, custom popup menu on right click using XML ribbon
body: <p>In my VSTO addin, I pop a custom menu if someone right clicks a cell containing a valid bond CUSIP (finance industry jargon for a bond id).  The method below accomplishes this using CommandBars.  The question I have is how to accomplish the same using XML ribbon definitions.
  Here is the current code using command bars (works fine):</p>
  
  <pre><code>    private static Office.CommandBar cbBondPopup = null;
      private void Application_SheetBeforeRightClick(object Sh, Excel.Range Target, ref bool Cancel)
      {
          Cancel = false; // overridden to true by btn1, btn2, btn3 handlers below (so that Excel Cell Menu is cancelled)
          if (IsBondCusip(this.Application.ActiveCell.Value2))
          {
              if (cbBondPopup == null &amp;&amp; IsBondCusip(this.Application.ActiveCell.Value2))
              {
                  // create command bar if nec
                  cbBondPopup = this.Application.CommandBars.Add(Name: "BondMenu", Position: Office.MsoBarPosition.msoBarPopup, Temporary: true);
                  // define 3 custom buttons
                  var btn1 = (Office.CommandBarButton)cbBondPopup.Controls.Add(Type: Office.MsoControlType.msoControlButton, Temporary: true);
                  var btn2 = (Office.CommandBarButton)cbBondPopup.Controls.Add(Type: Office.MsoControlType.msoControlButton, Temporary: true);
                  var btn3 = (Office.CommandBarButton)cbBondPopup.Controls.Add(Type: Office.MsoControlType.msoControlButton, Temporary: true);
                  btn1.Caption = "Bond Summary"; btn2.Caption = "Bond Details"; btn3.Caption = "Find Similar Bonds";
                  // connect buttons to handlers ==&gt; CmdBarEventHndlr(CommandBarButton Ctrl, ref bool Cancel)
                  btn1.Click += Click_BondSummary; btn2.Click += Click_BondDetails; btn3.Click += Click_FindSimilarBonds;
              }
              cbBondPopup.ShowPopup(); // pop bond menu (handlers set Cancel to true so Excel Cell Menu is cancelled unless user hits ESC)
          }
      }
  </code></pre>
  
  <p>Next, here are the same buttons defined in XLM ribbon syntax.  In this case the onAction methods have a different signature - e.g. Click_BondSummary(Office.IRibbonControl ctrl).</p>
  
  <pre><code>    &lt;button id="btnBondSummary" label="BondSummary" onAction="Click_BondSummary"/&gt;
      &lt;button id="btnBondDetails" label="BondDetails" onAction="Click_BondDetails"/&gt;
      &lt;button id="btnFindBonds"   label="FindBonds"   onAction="Click_FindSimilarBonds"/&gt;
  </code></pre>
  
  <p>I was hoping I could just put these definitions into an XML context menu and pop that.  By setting idMso="ContextMenuCell" I can cause the buttons to show up in the Excel Cell menu itself - but that's not what I want.  I want them to pop up in their own standalone popup menu.</p>
  
  <p>QUESTION:  Is there a way to rewrite my right-click handler using XML ribbon button definitions instead of command bars? (Otherwise I need two definitions of everything - one for the ribbon and one for the command bar popup).</p>