简体   繁体   中英

How to add nested context menu - visual studio addin

I created the extension for Visual Studio 2015 which looks this

But i want to place all the four menus in a category say My Group . Which should like this .

  • My Group [On click of this the rest of submenus shoud come same as shown in the image]
    • menu one
    • menu two

My vsct file looks like this

<Commands package="package">    
    <Groups>
      <Group guid="PackageCmdSet" id="MenuGroup" priority="0x0300">
        <Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_ITEMNODE"/>
      </Group>

      <Group guid="ClassPackageCmdSet" id="ProjectMenuGroup" priority="0x0400">
        <Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_PROJNODE"/>
      </Group>
    </Groups>

and i have buttons like this

 <Buttons>    
      <Button guid="PackageCmdSet" id="BranchModelClassId" priority="0x0100" type="Button" >
        <Parent guid="PackageCmdSet" id="MenuGroup" />
        <Icon guid="guidImages" id="bmpPic1" />
        <CommandFlag>DynamicVisibility</CommandFlag>
        <Strings>
          <CommandName>Test</CommandName>
          <ButtonText>Test</ButtonText>
        </Strings>
      </Button>

How to created a nested menu which i shouwn in the second image ?

Please help me on this.

I finally figured out the way. The change has to be done in the vsct file.

Add menus first inside the Commands

  <Menus>
      <Menu guid="PackageCmdSet" id="MainMenu" priority="0x0100" type="Menu">
        <Parent guid="PackageCmdSet" id="MenuGroup" />
        <Strings>
          <ButtonText>Nested Menu</ButtonText>
        </Strings>
      </Menu>
 <Menus>

Then add groups

<Groups>
      <Group guid="PackageCmdSet" id="MenuGroup" priority="0x0200">
        <Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_ITEMNODE"/>
      </Group>

      <Group guid="PackageCmdSet" id="CommandsMenuGruop" priority="0x0300">
        <Parent guid="PackageCmdSet" id="MainMenu"/>
      </Group>
  <Groups>

The button should be like this

 <Buttons>
      <Button guid="PackageCmdSet" id="ClassId" priority="0x0100" type="Button">
        <Parent guid="PackageCmdSet" id="CommandsMenuGruop" />
        <Icon guid="guidImages" id="bmpPic1" />
        <CommandFlag>DynamicVisibility</CommandFlag>
        <Strings>
          <CommandName>Command</CommandName>
          <ButtonText>Item 1</ButtonText>
        </Strings>
      </Button>
  <Buttons>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM