none
Office 2007 Excel Addin - WPF ComboBox Collapses when Expanded

    Question

  • Hi,
    In my Excel Application level Addin I have a WPF window ( contains WPF combobox ) which opens as a Modeless dialog on a Ribbon Button click event.
    PROBLEM
    The dropdown list of a ComboBox control disappears when I release the mouse left button on the dropdown  arrow.
    If i opened the wpf window as a Modal dialog it works normally.

    Using winspector spy (tool to monitor window messages) i noticed that the WM_CAPTURECHANGED Message fires continuously when the combobox expands and immediately closes. if it was a modal dialog it fired only once
    FYI
    The Addin was developed using VS2008 SP1, Framework3.5 SP1, Office 2007/2010
    This problem occurs only for Excel Addin, the same code works good for Word, PowerPoint, Outlook

    Please help me in fixing this issue.
    Regards,
    Vignesh
    Thursday, May 19, 2011 12:49 PM

Answers

  • Hi,

     

    I don’t know how you add the WPF controls into custom pane. However, I see that Keith used ElemtHost to add WPF control. Generally, I use this class when I want to add some WPF controls into a document but ActionPane (document-level) or CustomPane (Application-level).

    Please check my reply in this thread:

    http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/87af26b3-b0b7-4d04-8bdf-0a67501277ff

    The common way we add WPF control to custompane is:

     

    1. Create an Excel add-in project

    2. Add user control (WPF) name UserControl1 and add reference to System.xaml

    3. Code the WPF control and Build the project successfully

    4. Add User Control from Window Form collection, named the control as UserControl2

    5. Drag and drop a UserControl1 to UserControl2, assign the position as you like

    6. Code the ThisAddIn.cs in this way:

     

            UserControl1 myWPF;

            UserControl2 winformControl;

            Microsoft.Office.Tools.CustomTaskPane pane;

            System.Windows.Forms.Integration.ElementHost myHost;

            private void ThisAddIn_Startup(object sender, System.EventArgs e)

            {

                myWPF = new UserControl1();

                winformControl = new UserControl2();

                pane = CustomTaskPanes.Add(winformControl, "WPFControl");

                pane.Visible = true;

                pane.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionRight;

             }

     

    I don’t know if do this like above, if not, please try it and see if the same issue will happen. If not, would you like to post your way so that we can reproduce the issue. If you can post screen capture of the issue, it will be really helpful to let me what happens on your side.


    Best Regards, Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, May 25, 2011 6:13 PM
    Moderator

All replies

  • Hi,

     

    I don’t know how you add the WPF controls into custom pane. However, I see that Keith used ElemtHost to add WPF control. Generally, I use this class when I want to add some WPF controls into a document but ActionPane (document-level) or CustomPane (Application-level).

    Please check my reply in this thread:

    http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/87af26b3-b0b7-4d04-8bdf-0a67501277ff

    The common way we add WPF control to custompane is:

     

    1. Create an Excel add-in project

    2. Add user control (WPF) name UserControl1 and add reference to System.xaml

    3. Code the WPF control and Build the project successfully

    4. Add User Control from Window Form collection, named the control as UserControl2

    5. Drag and drop a UserControl1 to UserControl2, assign the position as you like

    6. Code the ThisAddIn.cs in this way:

     

            UserControl1 myWPF;

            UserControl2 winformControl;

            Microsoft.Office.Tools.CustomTaskPane pane;

            System.Windows.Forms.Integration.ElementHost myHost;

            private void ThisAddIn_Startup(object sender, System.EventArgs e)

            {

                myWPF = new UserControl1();

                winformControl = new UserControl2();

                pane = CustomTaskPanes.Add(winformControl, "WPFControl");

                pane.Visible = true;

                pane.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionRight;

             }

     

    I don’t know if do this like above, if not, please try it and see if the same issue will happen. If not, would you like to post your way so that we can reproduce the issue. If you can post screen capture of the issue, it will be really helpful to let me what happens on your side.


    Best Regards, Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, May 25, 2011 6:13 PM
    Moderator
  • Hello,

    Does the solution suggested by Calvin works for you?


    Regards from Belarus (GMT + 2),

    Andrei Smolin
    Add-in Express Team Leader
    Thursday, May 26, 2011 8:55 AM