locked
help, IVsTrackSelectionEx does not work RRS feed

  • Question

  • I work at shell mode and create a custom project type and some editors (like UML modeling editor).
    I want the properties window can track the selection in editor (
    reference: http://www.clariusconsulting.net/blogs/pga/archive/2007/6/28.aspx),
    see the following code:

    Firstly, it works, but today I found it failed :-(  I really have no idea.

    The deisgnerHost selection works well, and no exception thrown.

    class MyWindowPane : WindowPane...

    {

    OnInit:

      selectionContainer = new SelectionContainer(false, false);



    On designerHost selection changed:

      IVsTrackSelectionEx trackSelection = this.GetService(typeof(SVsTrackSelectionEx)) as IVsTrackSelectionEx;



      selectionContainer.SelectableObjects = designerHost.Container.Components;

      selectionContainer.SelectedObjects = designerHost.GetSelectedComponents();

      trackSelection.OnSelectChange(selectionContainer);

    }


    Wednesday, March 10, 2010 9:09 AM

Answers

  • Hi, Kuo

    designerHost.GetSelectedComponents() works well, the components are selected correctly when the mouse clicked.

    The trackSelection works again, I dn't know why, but it did.

    Forgot it, maybe my fault.

    BTW: Kuo, you are at Redmond?
    • Marked as answer by Chao Kuo Friday, March 26, 2010 2:27 AM
    • Marked as answer by Chao Kuo Friday, March 26, 2010 2:27 AM
    Friday, March 12, 2010 8:58 AM

All replies

  • Hello, Lee

    You code is right.

    Do you use ISelectionService selectionService = host.GetService(typeof(ISelectionService)) as ISelectionService;to get the components selection Change event?

    When it doesn’t work, have you tried to debug to see the value of designerHost.GetSelectedComponents(); ?

    I am not able to reproduce your issue, It works on my side.

    Could you provide more details?

    Thanks

    Chao

    Friday, March 12, 2010 5:34 AM
  • Hi, Kuo

    designerHost.GetSelectedComponents() works well, the components are selected correctly when the mouse clicked.

    The trackSelection works again, I dn't know why, but it did.

    Forgot it, maybe my fault.

    BTW: Kuo, you are at Redmond?
    • Marked as answer by Chao Kuo Friday, March 26, 2010 2:27 AM
    • Marked as answer by Chao Kuo Friday, March 26, 2010 2:27 AM
    Friday, March 12, 2010 8:58 AM
  • No, I am in Shanghai, China.
    Tuesday, March 16, 2010 2:47 AM