3

In a Visual Studio extension, I have defined a Toolbar in my .vsct file as:

      <Menu guid="guidVsCmdSet" id="MyToolbar" type="Toolbar" >
        <CommandFlag>TextChanges</CommandFlag>
        <CommandFlag>DefaultDocked</CommandFlag>      
        <Strings>
          <ButtonText>My Tools/ButtonText>
        </Strings>
      </Menu>

When I launch my extension in Visual Studio Experimental hive, I can open my Toolbar manually via right clicking in the CommandBar area.

Is there any way to have the toolbar show up by default when I first run the extension?

I have tried a couple other CommandFlags, but they did not seem to perform this behavior:

    <CommandFlag>AlwaysCreate</CommandFlag>
    <CommandFlag>DontCache</CommandFlag>   
Sheldon Warkentin
  • 1,706
  • 2
  • 14
  • 31

1 Answers1

3

What you want to look at is Visibility Constraints. The below example uses GUID_TextEditorFactory which makes it visible when a text editor is active (and hide when, for example a designer is active).

I'm not 100% sure what the correct context is to make it always visible, but my guess is UICONTEXT_NoSolution (or maybe GUID_VSStandardCommandSet97).

<CommandTable>
    <Commands.../>
    <VisibilityConstraints>
        <VisibilityItem guid="guidVsCmdSet" id="MyToolbar" context="GUID_TextEditorFactory" />
    </VisibilityConstraints>
</CommandTable>
Chris McGrath
  • 1,037
  • 1
  • 11
  • 22
  • Works like charm! See the "Using visibility contexts" section in [this link](http://dotneteers.net/blogs/divedeeper/archive/2008/04/17/LearnVSXNowPart18A.aspx) for some details about the context. – Amir Gonnen Nov 25 '12 at 06:40
  • UICONTEXT_NoSolution show only on startup. If there are no solution. I can add UICONTEXT_EmptySolution, UICONTEXT_SolutionHasMultipleProjects and UICONTEXT_SolutionHasSingleProject.... Is it possible to have only one option to autoload and show always? like standard toolbar in VS? – vik_78 Aug 16 '16 at 16:02