none
vsto excel context menu in custom task pane wpf problem RRS feed

  • Question

  • I am having a problem with Excel 2007 when I create a wpf usercontrol and add it to a custom task pane in excel, if I bring up a context menu and click on any of the items that are out of the window and over the excel sheet, the menu item does not receive the click event and just goes away. I can click any of the menu items that are inside the custom task pane, but none outside the window border. I don't have this issue with a context menu from a winforms control.
    in my addin startup I have this

    _usrCtrl =

    new UserControl();

    eh =

    new ElementHost();

    _usrCtrl.Controls.Add(eh);

    eh.Child =

    new WpfControlLibrary1.UserControl1();

    eh.Child.AddHandler( System.Windows.

    UIElement.PreviewMouseDownEvent,

     

    new System.Windows.RoutedEventHandler( PreviewMouseDown_Event ),

     

    true );

    eh.Dock =

    DockStyle.Fill;

    _usrCtrl.Visible =

    true;

    _ctp =

    this.CustomTaskPanes.Add(_usrCtrl,"Custom Task Pane");

    _ctp.DockPosition = Microsoft.Office.Core.

    MsoCTPDockPosition.msoCTPDockPositionTop;

    _ctp.Height = 140;

    I do not get the preview mouse down event when clicking on any menuitems outside the custom task pane window.

    Tuesday, November 10, 2009 10:21 PM

Answers

All replies

  • Hello,

    As you mentioned above, I am not able to reproduce this issue. When in this custom task pane, there is no context menu. I guess you means context menu of excel not custom task pane.

    << I bring up a context menu and click on any of the items that are out of the window and over the excel sheet, the menu item does not receive the click event and just goes away. >>
    Would you please give more about context menu and click event? To reproduce this issue, could you tell us the steps of reproducing?

    Best regards,
    Bessie
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, November 16, 2009 6:02 AM
  • No, the context menu comes from the wpf control that is embedded in the task pane, not from excel or the task pane itself. So I right click on a control within my wpf control and the popup menu appears. hope that clears it up
    Monday, November 16, 2009 2:00 PM
  • Hello again Bill,

    In my side, I am still not able to see this context menu of wpf control. Here I will post the steps of creating this project.

    1. Create an Excel 2007 Add-in project(TestExcelAddIn), and add a new project of which template is WPF User Control Library(WpfControlLibrary1). 

    2. In UserControl1.xaml of WpfControlLibrary1 project, add a button, label and textblock control. 

    3. In TestExcelAddIn project, add references to PresentationCore, PresentationFramework, WindowsBase, and WindowsFormsIntegration and WpfControlLibrary1 project.

    4. Now in ThisAddIn_Starup, write code like this,

            private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {
                Microsoft.Office.Tools.CustomTaskPane cust;
                UserControl1 uc = new UserControl1();
                System.Windows.Forms.Integration.ElementHost eh;
                eh = new ElementHost();
                uc.Controls.Add(eh);
                eh.Child = new WpfControlLibrary1.UserControl1();
                eh.Dock = DockStyle.Fill;
                cust = this.CustomTaskPanes.Add(uc, "Custom Task Pane");
                cust.Visible = true;
            }


    When I debug this solution and right-click in task pane, it does not show a content menu.

    If there is a difference between us, please point me out. To reproduce this issue, could you tell us the steps of reproducing?

    Best regards,
    Bessie


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Edited by Bessie Zhao Wednesday, November 18, 2009 1:43 AM
    Tuesday, November 17, 2009 2:39 AM
  • the problem is not the context menu showing, it does, it's when one or more of the items on the context menu is outside the bounds of the task pane and over the excel spreadsheet. So if you dock the task pane on the top and right click on the bottom to bring up the context menu, it will hang over the spreadsheet, then pick the last item on the menu. The menu goes away, but the click event is not sent to the control and whatever was under the item, for example a cell, acts as if you had just clicked on it.
    Tuesday, November 17, 2009 12:12 PM
  • Sorry for taking your time. Now I can reproduce this issue in my side.

    As Ji said in this thread, this is bug in Visual Studio, and will update this again when we are able to fix this issue in a future release.  This bug has been submitted to  http://connect.microsoft.com/VisualStudio. Here is the link you could refer to: http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=432998.

    Thanks again for this feedback.

    Best regards,
    Bessie


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Bessie Zhao Thursday, November 19, 2009 2:46 AM
    Wednesday, November 18, 2009 2:41 AM
  • The link to http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=432998 appears to be dead. I can confirm that this bug is still present in Visual Studio 2012 RC. :-(
    Friday, August 10, 2012 6:26 AM
  • Year 2019. December. Bug still present... 
    Monday, December 2, 2019 6:04 PM