Show a Visual Studio Extension Toolbar by default

徘徊边缘 提交于 2019-12-19 10:21:52

问题


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>   

回答1:


Read about how to do that in this workaround: LVN! Sidebar #7 - Showing a toolbar at Visual Studio startup




回答2:


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>


来源:https://stackoverflow.com/questions/11035795/show-a-visual-studio-extension-toolbar-by-default

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!